Install phpMyAdmin on Windows 10 WSL with Apache

How to Install phpMyAdmin on Windows 10 WSL with Apache Server

This post shows how to install phpMyAdmin on Windows 10 WSL (Windows Subsystem for Linux) with Apache HTTP server and Ubuntu 18.04 | 20.04 operating system.

phpMyAdmin is free and open source administration application for manage MySQL and MariaDB databases servers using a web interface. It is written in PHP and introduced on September 9, 1998. The main purpose of using phpMyAdmin is to handle the all database tasks and queries of MySQL over the web.

Using phpMyAdmin, you can easily manage MySQL databases(create, update, drop, alter, delete tables), import and export MySQL database content, manage user accounts and privileges, and many other operations.

With the help of WSL, you can easily install full Linux operating system in your Windows 10 system. You just need to enable WSL (Windows Subsystem for Linux) in your Windows, install a Linux OS, install and run phpMyAdmin.


How to Install phpMyAdmin on Windows 10 WSL

Simply follow below steps to install phpMyAdmin on Windows 10 WSL with Ubuntu OS :

Step 1 : Enable WSL in Windows 10

First of all, you will need to enable WSL in your Windows system. To enable it, simply open PowerShell terminal as administrator.

Click on Start icon -> search for PowerShell -> right-click Windows PowerShell app -> choose to run as administrator.

Run-powershell

Next, run the command below in the Windows PowerShell console as show below:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

The command above will display a successful message similar as below:

Deployment Image Servicing and Management tool
Version: 10.0.19041.844

Image Version: 10.0.19042.985

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Step 2 : Enable Virtual Machine Platform

Run the commands below from the same PowerShell console to enable the Virtual Machine platform in your Windows system:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

If you have Windows 10 version lower than 2004 in your system, use the commands below:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

Next, restart your computer for changes to apply. If you forget to start then the below command doesn’t work.

After restart of your computer, launch the PowerShell as administrator again and run the commands below to set WSL 2 as the default version of WSL:

wsl --set-default-version 2

Step 3 : Install Ubuntu in Windows 10

At this stage, WSL 2 is installed and ready to be used. So now you can easily install Linux operating(Ubuntu) system in your Windows 10 system.

Ubuntu 20.04 LTS on Windows WSL allows you to use Ubuntu Terminal and run Ubuntu command line utilities such as bash, ssh, git, apt and many others.

Click the below button to download and install Ubuntu 20.04 LTS from Microsoft Windows store.

download-ubuntu

Click on the Get button to Download and Install Ubuntu. After installing Ubuntu, launch it from WSL environment.

After launching, it will install and prompt to create your account as show below :

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: studiesonline
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

Use some troubleshooting commands when you get issues above. Run the below troubleshooting commands and launch Ubuntu again:

wsl --set-default-version 1
bcdedit /set hypervisorlaunchtype auto start

Step 4 : Install Apache HTTP Server

Run the commands below to install Apache2 HTTP on Ubuntu server:

sudo apt update
sudo apt install apache2

Next, you can use the commands below to stop, start and restart Apache2 services:

sudo service apache2 stop
sudo service apache2 start
sudo service apache2 restart

For check if Apache2 server is installed and working, simply open your browser and type server IP or hostname.

If browser show result similar like below then Apache2 is installed and working properly.

http://localhost
apache-default-page

Step 5 : Install MariaDB Server

To install MariaDB database server, simply run the commands below:

sudo apt update
sudo apt install mariadb-server mariadb-client

Next, you can use the commands below to stop, start and restart MariaDB service :

sudo service mysql stop
sudo service mysql start
sudo service mysql restart

Now, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.

sudo mysql_secure_installation

When you run the above command, it will prompted to answer the questions as show below:

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

For check if MariaDB is installed and working, run the command below:

sudo mysql -u root -p

When prompted, type the root password.

If you see the similar lines as below, then the MariaDB server was successfully installed.

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 46
Server version: 10.3.29-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

Step 6 : Install PHP and Related Modules

To install PHP and related modules, run the command below:

sudo apt install php libapache2-mod-php php-common php-mysql php-gmp php-curl php-intl php7.4-mbstring php-xmlrpc php-gd php-xml php-cli php-zip

After installing the PHP and related modules, run the commands below to verify that PHP is installed and working:

php -v
Output
PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

You can also test the PHP installation using a test php script. To do that, create a test PHP file called phpinfo.php in the server’s default home directory using command below.

sudo nano /var/www/html/phpinfo.php

Then simply copy and paste the below line into the test file and save it.

<?php phpinfo( ); ?>

Save the file and exit.

Restart the Apache2 using command below:

sudo service apache2 restart

Next, open your browser and browse to the server hostname or IP address followed by phpinfo.php as show below:

http://localhost/phpinfo.php

When test file is open, you see the PHP default page

Install phpMyAdmin on Windows 10 WSL-Apache-default-page

Step 7 : Install phpMyAdmin

In the above steps, we have successfully installed Apache, MariaDB and PHP. Next, run the commands below to install phpMyAdmin:

sudo apt install phpmyadmin

It will be prompted to select the web server for phpMyAdmin. Select apache2 when prompted and continue installing process:

+------------------------+ Configuring phpmyadmin +-----------------------+
| Please choose the web server that should be automatically configured to |
| run phpMyAdmin.                                                         |  
| Web server to reconfigure automatically:                                |
|                                                                         |
|    [*] apache2                                                          |
|    [ ] lighttpd                                                         |                                                         
|                                 <Ok>                                    |                                         
+-------------------------------------------------------------------------+

After select the web server, it will be prompted again to configure the database for phpMyAdmin, select Yes.

 +------------------------+ Configuring phpmyadmin +-----------------------+
 |                                                                         |
 | The phpmyadmin package must have a database installed and configured    |
 | before it can be used.  This can be optionally handled with             |
 | dbconfig-common.                                                        |
 |                                                                         |
 | If you are an advanced database administrator and know that you want to |
 | perform this configuration manually, or if your database has already    |
 | been installed and configured, you should refuse this option.  Details  |
 | on what needs to be done should most likely be provided in              |
 | /usr/share/doc/phpmyadmin.                                              |
 |                                                                         |
 | Otherwise, you should probably choose this option.                      |
 |                                                                         |
 | Configure database for phpmyadmin with dbconfig-common?                 |
 |                                                                         |
 |                  <Yes>                  <No>                            |
 |                                                                         |
 +-------------------------------------------------------------------------+

Next, enter the password and confirm for phpMyAdmin to register with the database, after that select OK and complete the installation process.

The current version of MySQL and MariaDB have a unique feature that provides root authentication via a auth_socket plugin. It authenticates users that connect from the localhost through the socket file without prompting or using a password.

This plugin creates issues with some applications who requires to connect with the database via root. To fix this problem or issue, you need to change default authentication process from auth_socket to mysql_native_password.

For do that, login back into the MySQL console.

sudo mysql

Next, run the commands below to change to mysql_native_password :

USE mysql;
UPDATE user SET plugin='' WHERE user ='root';

Save your changes and exit:

FLUSH PRIVILEGES;
EXIT;

Restart the Apache2 using command below:

sudo service apache2 restart

Next, open the browser and browse for the below URL to access phpMyAdmin dashboard:

http://localhost/phpmyadmin

It will open the phpMyAdmin login page:

Install phpMyAdmin on Windows 10 WSL-Phpmyadmin-login-page

Login and manage your database server from phpMyAdmin Dashboard.


That’s all

If you face any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

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

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

Scroll to Top