Setting up PHPMyAdmin for NginX

PHPMyAdmin (PHP + MySQL + Admin) is a popular PHP based GUI front end for MySQL administration. But for anyone who’s tried to install it on top of an LEMP stack knows that it doesn’t allow an automated config for NGINX, and can often leave new users dumbfounded about how to access the application. For NGINX setups, you will have to manually do this.

Installing PHPMyAdmin

First, we will make sure the system is updated.

#apt-get update
#apt-get dist-upgrade

Next, we install PHPMyAdmin.

#apt-get install phpmyadmin

When prompted to configure phpmyadmin, select “yes”.

Enter a password when it asks you to do so. Remember this password.

In the next prompt, choose not to configure for a web server. This is because you are running NGINX, and that’s not a choice.

Configuring NGINX to serve PHPMyAdmin

At this point, you have successfully installed the package on your system, but have no way to access it. We only need to write a quick nginx config to point to the installed path of PHPMyAdmin.

The package is installed to /usr/share/ . But, we can always create a sym-link to the place from a convenient webroot location. To do so,

$cd /path/to/webroot
$ln -s /usr/share/phpmyadmin phpmyadmin

Next, we need to write an NGINX config to actually use phpmyadmin from the webroot. Make the server listen to your favorite port number, and ask it to serve the webroot for phpmyadmin.

Once you have written and enabled this config file, simply reload or restart nginx to then access the application console via, where this new nginx config serves for

#service reload nginx

2 thoughts on “Setting up PHPMyAdmin for NginX

    1. Aaruni Post author

      I initially thought of including that, but it felt out of place in the article. I will include a sample config in a revision.

Leave a Reply

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

%d bloggers like this: