Install phpMyAdmin on Ubuntu 16.04 LTS with Nginx, MariaDB and PHP 7.1 Support

For new webmasters and website owners, the easiest way to manage MariaDB databases is via phpMyAdmin web based tool… The reason it’s easy is because all database management is done in the browser… not complicated database queries and commands.

So, if you’re new and need help managing MariaDB databases using phpMyAdmin, the steps below is a good starting point.

phpMyAdmin is a web-based tool that allows users to easily manage MySQL or MariaDB databases. For those not comfortable managing MariaDB databases via Linux command line , they may want to try phpMyAdmin web interface instead.

This brief tutorial shows students and new users how to install phpMyAdmin with Nginx, MariaDB and PHP support on Ubuntu 16.04 LTS server . This post should be short and easy to follow.

To get started, continue with the steps below:

Step 1: Install MariaDB Database Server

Run the commands below to install MySQL database server

sudo apt update
sudo apt install mariadb-server mariadb-client

After installing the server above, run the commands below to set a root password, remove the test database and disable the root from logging on remotely.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

Restart MariaDB server

sudo systemctl restart mysql.service

Step 2: Install Nginx HTTP Server

Next, run the commands below to install Apache2 HTTP Web Server

sudo apt install nginx

Step 3: Configure Nginx HTTP Server

Now run the commands below to configure Nginx basic settings. These are the basics.. and more advanced configurations can be done later.

First, confirm that your Nginx server configuration has Nginx Index directives for php defined. To run PHP based apps, Nginx must have index.php as a directory index in its site config file.

sudo nano /etc/nginx/sites-available/default

Make sure index.php is defined on the Index line in the site configuration file… Also, make sure that the PHP FastcGI section highlighted below is no commented out.. Save the file and exit.

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;


        location ~ \.php$ {
           include snippets/fastcgi-php.conf;
           fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include fastcgi_params;

Save the file and restart Nginx

sudo systemctl restart nginx.service

Step 4: Install PHP 7.1-FPM and Related Modules

PHP 7.1 isn’t available on Ubuntu default repositories… in order to install it, you will have to get it from third-party repositories.

Run the commands below to add the below third party repository to upgrade to PHP 7.1

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Then update and upgrade to PHP 7.1

sudo apt update

Run the commands below to install PHP 7.1 and related modules.

sudo apt-get install php7.1-fpm php7.1-mysql php7.1-cgi php7.1-common php-pear php7.1-mbstring

Step 5: Install phpMyAdmin

Now that Nginx and PHP are installed the final step is to install phpMyAdmin and configure. To do that, run the commands below

sudo apt-get install phpmyadmin php-gettext

When prompted to choose the webserver, don’t select anything… just skip and continue. We’re using Nginx webserver and it’s not on the list, so just skip.

+------------------------+ Configuring phpmyadmin +-------------------------+
 | Please choose the web server that should be automatically configured to   |
 | run phpMyAdmin.                                                           |
 |                                                                           |
 | Web server to reconfigure automatically:                                  |
 |                                                                           |
 |    [ ] apache2                                                            |
 |    [ ] lighttpd                                                           |
 |                                                                           |
 |                                                                           |
 |                                 <ok>                                      |
 |                                                                           |

When prompted again to allow debconfig-common to install a database and configure select No.

 +------------------------+ Configuring phpmyadmin +-------------------------+
 |                                                                           |
 | The phpmyadmin package must have a database installed and configured      |
 | before it can be used.  This can be optionally handled with               |
 | dbconfig-common.                                                          |
 |                                                                           |
 | If you are an advanced database administrator and know that you want to   |
 | perform this configuration manually, or if your database has already      |
 | been installed and configured, you should refuse this option.  Details    |
 | on what needs to be done should most likely be provided in                |
 | /usr/share/doc/phpmyadmin.                                                |
 |                                                                           |
 | Otherwise, you should probably choose this option.                        |
 |                                                                           |
 | Configure database for phpmyadmin with dbconfig-common?                   |
 |                                                                           |
 |                  <Yes>                   <No>                             |
 |                                                                           |

After installing phpMyAdmin, run the commands below to create a symbolic link to phpMyadmin content.

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

Now, open your web browser and login to the server hostname or IP address followed by phpmyadmin


phpmyadmin logon page on ubuntu

Logon with MySQL root account you created earlier…

That’s it!

If you get error #1698 – Access denied for user ‘root’@’localhost’ as shown in the image below, then read this post to fix.

ubuntu phpmyadmin


phpmyadmin nginx ubuntu

You may also like the post below:

One Reply to “Install phpMyAdmin on Ubuntu 16.04 LTS with Nginx, MariaDB and PHP 7.1 Support”

  1. Hello, I have tried this tutorial, but I can’t access the phpmyadmin. It’s said this site can’t be reached, but I can ping the IP. Do you have any solution for my problem?

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.