Install phpMyAdmin on Ubuntu 17.04 | 17.10 with Nginx, MariaDB and PHP-FPM Support

Looking for an easy way to manage MariaDB databases? You may want to try phpMyAdmin web based tool… Below is how to get it installed on Ubuntu.

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.

phpMyAdmin relies on the LAMP or LEMP stack to function. LAMP or LEMP is a collection of open source software that enable dynamic websites and applications to function. So before getting phpMyAdmin to function, lets get LEMP installed.

This brief tutorial shows students and new users how to install phpMyAdmin with Nginx, MariaDB and PHP support on Ubuntu 17.04 | 17.10 . 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 mariadb.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;


         # pass PHP scripts to FastCGI server
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass;

Save the file and restart Nginx

sudo systemctl restart nginx.service

Step 4: Install PHP-FPM and Related Modules

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

sudo apt-get install php-fpm php-cgi php-mysql php-common php-pear php-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:


  1. Well, every things installed. but when I tried to access phpmyadmin it shows 502 bad gateway.

  2. Tried to following this, but I got error:
    The mysqli extension is missing. Please check your PHP configuration. See our documentation for more information.

    help please,

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.