WAMP/LAMP Install on Windows WSL

TL;DR: Installed Ubuntu with WSL, in order to replace WAMP software and use the LAMP stack. Steps here.

I’ve recently made the switch back from MacOS to Windows 10. However, one of the biggest issues for me has been the lack of familiarity in web development tools for Windows and quickly grew to miss MAMP Pro on my MacBook. I though about spinning up a virtual machine, but didn’t want to waste system resources for a simple LAMP stack. I researched alternatives and found Windows Subsystem for Linux (WSL). WSL basically allows you to install your favorite Linux distro, meaning you can install a LAMP stack on Windows as a viable means to replace WAMP software. First you’ll need to install Ubuntu. You can find the instructions on how to do so on ubuntu.com.

How to install WAMP/LAMP stack on Windows using Ubuntu:

Apache Install

Open Ubuntu app:
Start menu > Type “Ubuntu” > Click Ubuntuwindows start menu showing ubuntu app

Update Ubuntu:
type sudo apt-get update

ubuntu terminal running command

Install Apache:
type sudo apt-get install apache2
type y when prompted

Test Apache Install
Start Apache by typing sudo apache2ctl start

Note: You may receive a firewall warning, if so, click “Allow access”

In browser type: http://localhost

PHP Install

Type sudo apt-get install php libapache2-mod-php mcrypt php-mysql

*Installs PHP and other modules to connect Apache to PHP and MySQL

Test PHP Install

Restart Apache:
sudo apache2ctl stop
sudo apache2ctl start

Create PHP test file:

type sudo nano phptest.php

In nano editor type: <?php phpinfo() ?>

In browser type: http://localhost/phptest.php

Install MySQL

Type sudo apt-get install mysql-server

Setup root user and password:
Start mysql service with sudo service mysql start
Type sudo mysql -u root -p
Leave password blank to connect

Type the following SQL query:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'P@ssw0rd';

Note: Replace P@ssw0rd with stronger password.

phpMyAdmin Install

type sudo apt-get install phpmyadmin

Select Apache as default web server:

Hit Enter key, to configure database for phpMyAdmin with default dbconfig-common file

Set password

Edit Apache config file located at /etc/apache2/apache2.confType sudo nano /etc/apache2/apache2.conf and add following lines:
ServerName localhost
Include /etc/phpmyadmin/apache.conf

Restart Apache server

sudo apache2ctl stop
sudo apache2ctl start

phpMyAdmin Test

Go to https://localhost/phpmyadmin

Username will be root, password is your MySQL password

Now you are ready to install a content management system (CMS) like WordPress, Drupal, or any system which utilizes a WAMP stack. 

0 thoughts on “WAMP/LAMP Install on Windows WSL

  • Great resource! I found a few mistakes so I wanted to document how
    I fixed them for future users.

    When testing Apache, the line “ should be “ (without the space between ? and php).

    I had to start the MySQL server with `sudo service mysql start`.

    You should edit the Apache config with `sudo nano /etc/apache2/apache2.conf` (.conf, not /conf).

    Other than that everything worked exactly how you said it would.

    • Thank you for pointing that out. Much appreciated. I’ve removed the space from the PHP code for the phptest.php file, updated the command to edit the apache.conf file, and added the command to start the MySQL service before setting the root password.

      Glad that this was helpful!

      Cheers

  • This was one of the simplest and most thorough tutorials I have ever come across. I just so happened to be updated my WSL program structure, and your article provided all the information I couldn’t recall to accomplish this. Well done, and thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

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