How to Install phpMyAdmin with Nginx on CentOS 7

Published on

3 min read

Install phpMyAdmin with Nginx on CentOS 7

phpMyAdmin is an open-source PHP based tool for managing MySQL and MariaDB servers over a web-based interface.

phpMyAdmin allows you to interact with MySQL databases, manage user accounts and privileges, execute SQL-statements, import and export data in a variety of data formats and much more.

In this tutorial, we will show you how to install phpMyAdmin with Nginx on CentOS 7.


Ensure that you have met the following prerequisites before continuing with this tutorial:

Although not necessary, it is advised to access your phpMyAdmin installation over HTTPS. If you don’t have SSL on your sites, follow the instructions about securing your Nginx with Let’s Encrypt on CentOS 7 .

Installing phpMyAdmin on CentOS

Use the following steps to install phpMyAdmin on a CentOS 7 system:

  1. phpMyAdmin is included in the EPEL repository . If you do not already have EPEL enabled you can do so by typing:

    sudo yum install epel-release
  2. Once the EPEL repository is enabled, install phpMyAdmin and all of it’s dependencies with the following command:

    sudo yum install phpmyadmin

    Make sure you have Nginx and PHP 7 installed on your system before installing phpMyAdmin.

  3. Change the group ownership of the /etc/phpMyAdmin directory to nginx (the user under which the PHP FPM service is running):

    sudo chgrp -R nginx /etc/phpMyAdmin

Configuring Nginx and phpMyAdmin

There are several ways how to configure the Nginx to serve phpMyAdmin files. If your domain’s server block is already set up to serve the PHP requests then you can simply create a symbolic link from the phpMyAdmin installation files to your domain document root directory.

In this guide we will create a snippet which we can include in any of our Nginx server block files.

Start by creating the snippets directory:

sudo mkdir -p /etc/nginx/snippets

Open your text editor and create the following file:

sudo nano /etc/nginx/snippets/phpMyAdmin.conf

Paste the following content:

location /phpMyAdmin {
       root /usr/share/;
       index index.php index.html index.htm;
       location ~ ^/phpMyAdmin/(.+\.php)$ {
               try_files $uri =404;
               root /usr/share/;
               fastcgi_pass unix:/run/php-fpm/www.sock;
               fastcgi_index index.php;
               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
               include /etc/nginx/fastcgi_params;
       location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
               root /usr/share/;
location /phpmyadmin {
    rewrite ^/* /phpMyAdmin last;
Make sure you are using the correct socket path or address/port for the fastcgi_pass directive.

Save the file and close your editor.

You can now add the following line to each domain’s server block where you want to access phpMyAdmin using:

include snippets/phpMyAdmin.conf;

Here is an example:

server {

    # . . . other code

    include snippets/phpMyAdmin.conf;

    # . . . other code


Accessing phpMyAdmin

To access the phpMyAdmin interface open your favorite browser and type your server’s domain name or public IP address followed by /phpmyadmin:


Enter the administrative user login credentials and click Go.

phpmyadmin login

Once you log in, you’ll see the phpMyAdmin dashboard, which will look something like this:

phpmyadmin interface


Congratulations, you have successfully installed phpMyAdmin on your CentOS 7 server. You can now start creating MySQL databases, users and tables and perform various MySQL queries and operations.

If you have questions, feel free to leave a comment below.