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.

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

ex. http://example.com/phpmyadmin

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.