In this tutorial, we learn how to Install and Secure phpMyAdmin with Nginx on Ubuntu 18.04.
phpMyAdmin is the most used free graphical interface for Mysql and MariaDB operations. phpMyAdmin having a wide range of operations on MySQL and MariaDB. If you do not like the command-line interface then you should try is once.
Table of Contents
Prerequisites :
Before we get started you will need Ubuntu 18.04 and Nginx installed. You can learn to get this done by our other tutorials “Ubuntu 18.04 LTS Desktop Installation with Screenshots” & “How To Install Latest Nginx 1.17, MySQL 8, PHP 7.3 (LEMP stack) on Ubuntu 18.04”.
Step 1: Installing phpMyAdmin with Nginx on Ubuntu 18.04
The very first thing we need to do is installing phpMyAdmin in Ubuntu. PhpMyAdmin is available in Ubuntu’s default repositories. So, We are going to use the same.
Note: All the commands in this tutorial are running withthe root permission. You have to use the sudo command if you are not using the root user.
Here we start with updating the package list with the below command:
root@iswblog:~$ apt-get update
Now, Install phpMyAdmin with the below command:
root@iswblog:~$ apt-get install phpmyadmin
During the installation process, you will be asked to choose the web-server ( Apache or Lighttpd ). But we are not going to use both of them, that’s why we do not choose any of them. Just press the tab key and select the OK option.
After that, you will be prompted to configuring the phpMyAdmin database. Select Yes and set a strong password for the PHPMyAdmin user for MySQL access.
The installation will complete now. Here we use the Nginx web server that’s why we need to do some configuration in Nginx so that it can serve the PHPMyAdmin application files. We are going to create a symbolic link of PHPMyAdmin application files in our Nginx document root folder with the help of below command:
root@iswblog:~# ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
After that step, our PhpMyAdmin installation is now operational. We can now access the application interface with entering our servers IP address or domain name followed by “/phpmyadmin” in our web browser.
http://server_domain_or_IP/phpmyadmin
Now login with any of your mysql users which are created by you or you can start with the root user. After that, you should able to access the administrative panel of phpMyAdmin.
Step 2: Secure phpMyAdmin with Nginx
The best method of securing any of the web applications is that you should hide it for the others. So here we are going to change the default URL of the PHPMyAdmin web interface.
By default, the application is having the URL “http://server_domain_or_IP/phpmyadmin” . We will change it to something non-standard. So that it will be harder to access the web application. First, navigate to the document root of Nginx where we create the symbolic link for the PHPMyAdmin and then run the below command :
root@iswblog:~# mv phpmyadmin mycustomname
Change mycustomname with your own alternate name. After this command, you can access your phpmyadmin web interface with the below URL.
http://server_domain_or_IP/mycustomname
Summary:
After doing the above procedures, you will be able to manage your MySql server from a secure web interface. Phpmyadmin providing most of the functionality available via the MySQL command line. Now you learned how to Install and Secure phpMyAdmin with Nginx on Ubuntu 18.04. Thanks for Reading. Happy Learning !!!
Recommended: How to Install Latest PHP 7.3 on Ubuntu 18.04