Step-by-Step Guide to Install phpMyAdmin on WSL Ubuntu 22.04

Installing phpmyadmin on Ubuntu

Step-by-Step Installation of phpMyAdmin on WSL Ubuntu 22.04

Apache
phpMyadmin
wsl
LAMP stack
Linux
MySQL
ubuntu

This guide will walk you through installing phpMyAdmin on your WSL (Windows Subsystem for Linux) running Ubuntu 22.04. However, before we dive into phpMyAdmin, we'll need to ensure we have a functioning LAMP stack (Linux, Apache, MySQL, PHP) set up.

Prerequisites:

WSL2 inside Windows and running Ubuntu 22.04

1. Update your system:

Begin by updating your package lists to ensure you have the latest information:

sudo apt update

2a. Install Apache:

Install the Apache web server using the following command:

sudo apt install apache2

2b. Verify Apache Installation:

Once installed, verify that Apache is up and running:

sudo systemctl status apache2

If Apache is running correctly, the output should show its status as "active."

In case systemctl malfunctions (which can sometimes happen in WSL), you can start Apache using the service command:

sudo service apache2 start

3. Configure Apache to Start on Launch (WSL-specific):

Since systemctl might not always work as expected on WSL, we'll recommend adding a configuration line to ensure Apache automatically starts when your WSL instance launches.

Here's how to edit your .bashrc file and add the line:

nano ~/.bashrc

Add the following line at the end of the file:

sudo service apache2 start

Save the changes and exit the editor.

4. Access the Apache Test Page:

Now, let's test if Apache is running by opening a web browser and navigating to:

http://localhost

You should see the default Apache Ubuntu page. This confirms that Apache is installed and functioning successfully.

5. Install phpMyAdmin:

Use the following command to install phpMyAdmin:

sudo apt install phpmyadmin

During the installation, you'll encounter prompts for:

  • Web server selection: Choose apache2 by pressing SPACE, then TAB, and finally ENTER.
  • Database configuration: Select Yes and press ENTER.
  • MySQL root user password: Enter the password for your MySQL root user.
  • phpMyAdmin application password: Choose and confirm a password for the phpMyAdmin application itself.

6. Enable Required PHP Extensions:

Ensure all required PHP extensions are enabled. You might need to install and enable extensions like mbstring if not already active:

sudo apt install php-mbstring php-zip php-gd php-json php-curl
sudo phpenmod mbstring

7. Configure Apache for phpMyAdmin:

In some cases, additional configuration might be required for Apache to recognize phpMyAdmin. Here's how to set it up:

Create a symbolic link of phpMyAdmin's Apache configuration file to the conf-enabled directory:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/phpmyadmin.conf

Restart Apache to apply the changes:

sudo service apache2 restart

8. Access phpMyAdmin:

Finally, open a web browser and access phpMyAdmin using your WSL IP address followed by /phpmyadmin:

http://<your_WSL_IP>/phpmyadmin

Note: Replace <your_WSL_IP> with your actual WSL IP address.

This should grant you access to the phpMyAdmin administration panel. You can now manage your MySQL databases directly through the web interface.

Additional Notes:

  • Ensure that your MySQL service is running. You can start it with:
    sudo service mysql start
  • If you encounter issues with phpMyAdmin not being found, ensure that the symbolic link was created correctly and that phpMyAdmin is installed in the expected directory.