How To Install phpMyAdmin on Ubuntu 16.04/18.04 LTS with Nginx & PHP-FPM

DigitalOcean Referral Badge
Start your VPS now with FREE $100 credit.

Running LEMP Stack (Linux, Nginx, MySQL/MariaDB, and PHP) without a control panel will certainly be quite difficult for beginners. Well, if you have LEMP Stack running on your cloud server, surely you will need a web-based interface administration tool to handle your MySQL or MariaDB database server. Out there we have two choices of administration tools for database servers, including phpMyAdmin and Adminer. However, in this tutorial I will guide you how to install and configure phpMyAdmin on the Ubuntu 16.04/18.04 LTS Server, which runs Nginx web server with PHP-FPM.

As we know that phpMyAdmin is the most popular MySQL/MariaDB administration tool in a shared web hosting environment. In fact it has become a standard feature in almost all control panels including cPanel-WHM, Plesk, VestaCP, Centos Web Panel (CWP), Webuzo, and Kloxo-MR. Of course, phpMyAdmin is completely free and it’s open source.

Well, if you want to install and configure phpMyAdmin on LEMP Stack, you need to follow the following guidelines. This tutorial should work well on both Ubuntu 16.04 and 18.04 LTS.

1.) phpMyAdmin is available in the official Debian/Ubuntu repository, so you only need to run the following command to install phpMyAdmin on your Ubuntu LTS server.

$ apt-get install phpmyadmin

During the phpMyAdmin installation process you will get several questions, including web server options and dbconfig-common. Although there’s no Nginx option during the phpMyAdmin installation process, you can choose apache as the default web server that will be automatically configured to run phpMyAdmin.

READ:  How To Install MultiPHP Version with Nginx on Ubuntu 16.04/18.04/19.04 LTS Server

Then you must press “YES” to configure database for phpMyAdmin with dbconfig-common. After that, enter the MySQL administrative password for phpMyAdmin. This is the password for phpMyAdmin users in the mysql database.

2.) Let’s create a symbolic link between phpMyAdmin and your website root directory.

$ ln -s /usr/share/phpmyadmin/ /var/www/yourdomain.com/public

Since Nginx’s default root directory is located at /var/www/html, we can also create a symbolic link to this default root directory.

$ ln -s /usr/share/phpmyadmin/ /var/www/html

3.) Next, we need to edit the default Nginx serverblock since we have created a symbolic link between phpMyAdmin and the default Nginx public directory. Here is my default serverblock configuration for phpMyAdmin.

nano /etc/nginx/sites-available/default
# Default server configuration for phpMyAdmin
#
server {
       listen 80 default_server;
       listen [::]:80 default_server;

       root /var/www/html;

       # Add index.php to the list if you are using PHP
       index index.php index.html index.htm index.nginx-debian.html;

       server_name 207.246.97.100; 

       #location / {
       # First attempt to serve request as file, then
       # as directory, then fall back to displaying a 404.
       # try_files $uri $uri/ =404;
       #}

       location / {
                try_files $uri $uri/ /index.php?$args ;
       }

       # pass PHP scripts to FastCGI server
       #
       location ~ \.php$ {
               include snippets/fastcgi-php.conf;
               include fastcgi_params;
               include fastcgi.conf;
               fastcgi_param HTTP_PROXY "";
               fastcgi_pass 127.0.0.1:9000;
       }

}

NOTE:

READ:  How To Fix MySQL Plugin 'auth_socket' is not loaded”

* Please replace 207.246.97.100 with your server’s IPv4 address
* You can access phpMyAdmin via http://your_IPv4_address/phpmyadmin

4.) All DONE; now you must restart Nginx dan PHP-FPM services

$ service nginx restart
$ service php5.6-fpm restart
$ service php7.0-fpm restart
$ service php7.1-fpm restart
$ service php7.2-fpm restart
$ service php7.3-fpm restart

Leave a Comment