Windows Subsystem for Linux

Setting up Windows Subsystem for Linux with Ubuntu and Apache2 webserver, a set by step guide.

Windows is now good for development! Yes, I said it, and its all thanks to Windows Subsystem for Linux (WSL). No more WAMP or Xampp, WSL can do everything you need.

Here you can find a step by step guide to setting up WSL, Apache2 and MySQL.

  • What is Windows Subsystem for Linux (WSL)
  • WSL setup
  • Apache2 Setup
  • MySQL Setup

What is Windows Subsystem for Linux (WSL) ?

For those who don’t already know what Windows Subsystem for Linux is, its a compatibility layer for running Linux binary executables on Windows 10. WSL is aimed for developers and allows those who need to use Bash, common Linux tools and other Linux-first tools on Windows.

WSL provides a terminal running Bash shell, where you can run Linux commands and tools. You can use APT package manager! From the terminal, you can also access both the Linux file system and the Windows file system (found in /mnt).

Setting Up Windows Subsystem for Linux with Ubuntu

First things first, we need to enable WSL on our machine. Open PowerShell as administrator and run:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Now its time to install the OS you want to run. In this example we will install Ubuntu from the Windows store, however you can install other distros directly from the Windows store or form the command line.

In the Windows Store, search and install Ubuntu, and once installed, open it. A console window will open which will initialise the instillation. This may take a few minuets. You will be asked to set the default user and password.

Once completed, search in the Cortana search bar for Bash.exe. You will be straight into the user directory.

Install lamp server

For our server, we will be using Apache2 and MySQL. Before we install lamp-server we need to run the following:

sudo apt-get update && sudo apt-get upgrade

Then run:

sudo apt-get install lamp-server^

Now we need to make some changes to the apach2.conf file. To open and edit the file run:

nano /etc/apache2/apache2.conf

You shouldn’t need to use for the moment, however if the above doesn’t work then append the command with sudo.
Now add the following 2 lines to the file.

Servername localhost
AcceptFilter http none

Now that Apache is set up, we can start the server.

sudo service apache2 start

To start MySQL run:

sudo mysql start

Linking your directory in windows with your server directory

Now that we have the basics set up and running, we can link our working directory within Windows with your WSL Apache server. If you have used different local environment set ups then this step will be familiar to you, but what this does is take a directory where you have all your projects within Windows, and makes them accessible to your server directory (linking the directories).


Create a directory within your User/Documents folder names projects. Then open bash.exe and run the following:

cd /
sudo ln -s /mnt/c/Users/windows-user-name-here/Documents/projects /var/www/html

So, thats it! Now you can create projects within your projects folder, make changes to files as you usually would, and run them by visiting localhost, which is severed from your Apache2 server on WSL.

I hope all the above has been helpful, and I hope you will soon be able to enjoy the wonders of Windows Subsystem for Linux. If you have any questions, please do leave them below and I will try and assist as soon as I can.