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/example.com

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)

/etc/nginx/sites-available/default

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 example.com/pma_hidden, you should be presented with an authentication window to enter the username and password to access your phpmyadmin.

Conclusion

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.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

Leave a Reply

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.

Solved Programs