The ULTIMATE guide to setup Windows Subsystem for Linux (WSL) with Ubuntu, Apache2, MySQL and PHP

By Dillon Smart · · · 2 Comments


Windows is now good for development! Yes! All thanks to Windows Subsystem for Linux (WSL). No more WAMP or Xampp, WSL can do everything you need. In this ultimate guide to setup Windows Subsystem for Linux with Ubuntu, Apache2, MySQL, and PHP we will cover:

What is Windows Subsystem for Linux?

Windows Subsystem for Linux is a compatibility layer for running Linux binary executables on Windows 10. WSL was created by Microsoft 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 Linux commands and tools can be executed. Packages and applications can be installed just as they would on any Linux machine, using package managers such as APT.

From the terminal, users can access both the Linux file system and the Windows file system, which can be found in the /mnt directory.

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.

In the Windows Store, search for Ubuntu, and once installed, open it. A console window will open which will initialize the instillation. This may take a few minutes. After installation has been completed, 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.

Alternatively, you can download Windows Terminal, from which you can open Ubuntu.

Install a LAMP server (Linux, Apache2, MySQL, PHP)

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 apache2.conf file. To open and edit the file run:

nano /etc/apache2/apache2.conf

You shouldn’t need to use sudo 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 start Apache2 using the following command:

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 setups 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 named projects (notice lower case).

Next, open your terminal or Bash.exe and run the following:

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

All done! Now you can create new directories and files within your projects folder, make changes to files as you usually would using your favorite IDE or text editor, and run them in your browser by visiting localhost, all of which is severed from your Apache2 server on WSL.

Apache2LinuxMySQLPHPUbuntuWindowsWindows Subsystem for Linux



[…] For help setting up WSL for web developers, check out The ULTIMATE guide to setup Windows Subsystem for Linux (WSL) with Ubuntu, Apache2, MySQL and PHP […]

I Know That Now

[…] In this post we will show you how to change PHP version on Ubuntu, Linux. This also works on WSL. Follow this guide to setup Windows Sub System for Linux. […]

Was this helpful? Leave a comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

How to grant full privileges to a user in MySQL

Updated 16th August 2022

After setting up a lamp stack development environement with phpmyadmin locally on Linux you may notice that your phpmyadmin user (or other user name) doesn’t have the correct privileges to create new databases. To use the phpmyadmin user to create new databases and users for those databases you need to grant full privileges to the

List of programming languages used for Web Development

Updated 16th August 2022

There are a wide variety of programming languages that can be used for web development. Which one you choose depends on your preferences and needs. Some languages are better suited for certain tasks than others. In this post, we’ll take a look at some of the most popular languages used for web development. JavaScript PHP

Pixel Tracking in PHP

Updated 16th August 2022

When creating email campaigns, it’s important to know how many recipients actually opened your email. This information can help you determine if your efforts are working or if it’s time to change your strategy. Most mail champaign tools such as Mailchimp and SendInBlue use a technique called Pixel Tracking. In this post, you will learn