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:

Change to the /var/www/html directory: cd /var/www/html

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.

Exit the mysql server by typing: exit

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.