How to install Apache, MySQL, PHP & PhpmyAdmin on Windows 10 WSL

If you are into web development, then I know you already familiar with LAMP stack that contains Apache, MySQL, PHP and PhpMyAdmin (optional) on a Linux platform. Yes, there are a couple of applications that provide LAMP in single install package to test various kinds of web applications on Windows 10/8/7 such as XAMPP and WAMP. However, if you are on Windows 10 then you don’t need them, you can get the native performance of Linux with command line interface to download, install and manage LAMP packages. And here in this tutorial, we let you know how to install MySQL, PHP and phpMyAdmin on Windows 10 using Windows Subsystem for Linux.

The Windows Subsystem of Linux which is basically Linux compatibility layer on Windows 10 to run various kind of minimal Linux distro images with command line interface. Such as Debian, Ubuntu, Kali, Arch Linux, OpenSUSE, CentOS and more… Some of them are officially available on the Windows 10 Microsoft Store such as Ubuntu. Here first, we will download Windows 10 WSL Ubuntu and in further steps, we will understand how to set up Apache, MySQL, PHP and phpMyAdmin (LAMP stack) on it. Thus, let’s start the tutorial.

Step 1: Enable Windows 10 WSL for LAMP installation

Installing Windows Subsystem for Linux is not a big deal, we don’t have to download some third-party packages at all. Just search for “Turns Windows features on or off” in the search box of Windows 10. Then find an option Windows subsystem for Linux, select and click the OK button.

On this topic, you can see our step by step article on how to activate Windows 10 WSL.

Step  2: Download WSL Linux Distro

The second thing we need is the Linux Distro on our WSL to install MySQL, PHP and phpMyAdmin. Although there are various Linux apps are available on Microsoft Store but here we are installing the Ubuntu 18.04 WSL. So, in the Windows 10 search box, type Microsoft Store and there search for Ubuntu. When it appears, click on the Get button to install it.

Step 3: Run Ubuntu 18.04 WSL

After installing, the Ubuntu will available in Windows 10 applications, click on it to run. To start properly it needs to download some extra packages, thus it will take some time, hence, be patient.

Run Ubuntu 18.04 WSL

Step 4: Run system update command

So, what we have now is exactly the Linux Ubuntu server in command line interface, thus the command will also be the same to install any Linux packages as we use in standard Ubuntu OS.

Although we have recently, installed the Ubuntu WSL distro, there will be a possibility of updates, thus first run the system update command:

sudo apt-get update 
sudo apt-get upgrade

Step 5: Install Apache on WSL

The first thing in a Linux based LAMP  stack is Linux OS itself which already have setup above, now what we need is Apache web server. It is a light open source web server to run different web apps and websites. To install it on Windows 10 subsystem for Linux use the below command:

sudo apt-get install apache2
sudo service apache2 start

install apache on WSL

Step 4: Installing MySQL on Windows 10 WSL

To install MySQL on Ubuntu Windows 10 WSL, here is the command:

sudo apt-get install mysql-server mysql-client
sudo service mysql start

Create a root user to use with phpMyAdmin later

sudo mysql -u root
CREATE USER 'h2s'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'h2s'@'localhost';
FLUSH PRIVILEGES;

Note: Change the green colour text i.e Username and password with whatever you want to assign.

Step 5: PHP installation in Ubuntu Windows 10 WSL

Here we are installing PHP along with some important PHP extensions that you might need for your web projects.

sudo apt-get install php libapache2-mod-php php-mysql php-gd php-json php-curl php-xml php-intl
sudo apt-get update

Step 6: Install phpMyAdmin

Its time to download and install phpMyadmin on Windows WSL. We already have installed the main components of a LAMP stack that we need to install and run most of the PHP based projects on Linux. However, if you not much profound in database commands to manage it you should install phpMyAdmin too. Here is the command for that:

sudo apt-get install -y phpmyadmin

While installing the installer will ask for a couple of things.

Give some password for phpMyAdmin to register with the database server.

Install phpMyAdmin

Choose the web server that you want to configure automatically with phpMyAdmin. As we have installed Apache thus use the Spacebar key to select the option apache2 and then press the Enter button.

Select the websrver for WSL

Congifure the database for phpmyadmin.

Configuration Phpmyadmin

When it asks for database user then simply type the one we have created above. In our case, it is h2s and you have to enter your created one.

root databse user for phpmyadmin

Step 7: Test Apache and phpMyadmin

After performing all the above steps, its time check whether everything is working or not. For that first, we have to know what is our Ubuntu WSl IP address.  Use the below command:

ifconfig

how to find IPAddress on Ubuntu Windows 10 WSL

Now open your browser and type your system IP which you find in the above step. In our case, it is 192.168.43.93 and must be different in yours.

install mysql php and phpmyadmin check

Test and Login to phpMyAdmin

To access the installed phpMyAdmin, type your system IP along with phpMyAdmin directory name as:

localhost/phpmyadmin

or

127.0.0.1/phpmyadmin

or using the local IP address, in our case it is:

192.168.43.93/phpmyadmin

When the login screen appears then type the root user for Database created above along with its password.

PHPmyadmin root login on WIndows WSL

Here is the Dashboard phpMyAdmin.

PHPmyadmin Dashboard

 

Leave a Reply

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