How to install phpmyadmin with Nginx on an Ubuntu 18.04 server

Here I am going to share how to install phpmyadmin with Nginx on an Ubuntu 18.04 server step by step. phpMyAdmin was created so that users can interact with MySQL through an intuitive web interface, running alongside a PHP development environment.

While many users need the functionality of a database system like MySQL, interacting with the system solely from the MySQL command-line client requires familiarity with the SQL language, so it may not be the preferred interface for some.

Ubuntu makes our life easier. To install PHPMyAdmin, just run the following in your terminal. To open the terminal press ctrl+alt+t

Step 1 — Install PHPMyAdmin

Now you will see two options. For our installation, we won’t select one of them. Press the tab button and enter OK. Enter password of MySQL when asked.

Step 2 — Setup PHPMyAdmin for NGINX

Step 3 — Congrates!

Yo have done all now restart you nginx server by using the below command.

Now you’ve PHPMyAdmin available on your server. You can check on localhost/phpmyadmin or yourhostname/phpmyadmin

Installing PHPMyAdmin on Ubuntu.

Secure phpMyAdmin (Optional)

This is a bonus to provide an additional layer of security to secure your phpmyadmin by set up an authentication in Nginx server.

Firstly, generate a strong password and keep it safe.

Install apache2-utils, which can generate the .htpasswd file by using below command

Once installed, we can generate the .htpasswd file. Simply change username to whatever username you want. Generate a password and keep it safe.

There should now be a .htpasswd file containing your username and encrypted password. You can check with:

You should see something like username:$apr1sdfsdf4435sdtskLfWmmg1sfdsdgg4

Now add two directives to Nginx configuration file. The location of the config file may vary depending on your setup, though the default is usually in /etc/nginx/sites-available/default. If you set up multiple domains in a previous guide, your config file may be located in somewhere like /etc/nginx/sites-available/

This this example, we will assume the config file is in /etc/nginx/sites-available/default. Open the file to edit.

Scroll down and look for the location block and paste in a new block underneath it with the name of your obscured phpMyAdmin folder, in this example pma_hidden. (Use the right mouse button to paste if using PuTTY for Windows)


Save file and exit (press CTRL + X, press Y and then press ENTER).

Check that the Nginx config file is valid, otherwise the server could crash on restart.

If valid, reload Nginx config.

Now when visiting, you should be presented with an authentication window to enter the username and password to access your phpmyadmin.


Here we learn about the installing PHPMyAdmin on ubuntu server After completing this tutorial, you should be able to manage your MySQL databases from a reasonably secure web interface.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts: