phpMyAdmin is a free and open-source, web-based administration tool for managing the MySQL and MariaDB servers. It is widely used to manage database servers by web hosting companies and administrators who are new to database servers.

phpMyAdmin helps an administrator to perform database activities such as creating, deleting, querying, tables, columns, etc.

This guide will help you to install phpMyAdmin with Nginx on CentOS 8 / RHEL 8

To install and use phpMyAdmin, you must have one database instance running on your system and the Nginx web server.

Follow the tutorials and prepare your system for installing phpMyAdmin.

READ: How To Install MariaDB on CentOS 8 / RHEL 8

OR

READ: How To Install MySQL on CentOS 8 / RHEL 8

AND

READ: How To Install LEMP Stack on CentOS 8 / RHEL 8

Install below PHP extensions for phpMyAdmin to connect with the database.

yum install -y php-json php-mbstring

READ: How To Install LEMP Stack on CentOS 8 / RHEL 8

Install below PHP extensions for phpMyAdmin to connect with the database.

yum install -y php-json php-mbstring

The phpMyAdmin is not available as an RPM package in OS repositories for CentOS 8 / RHEL 8. So, we will download the tarball from the official website.

wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz

Install phpMyAdmin using the following command.

tar -zxvf phpMyAdmin-4.9.0.1-all-languages.tar.gz

Move the phpMyAdmin directory to your desired location.

mv phpMyAdmin-4.9.0.1-all-languages /usr/share/phpMyAdmin

Copy the sample configuration file.

cp -pr /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php

Edit the configuration file and add the blowfish secret.

vi /usr/share/phpMyAdmin/config.inc.php

Generate blowfish secret and update the secret in the below line.

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Import the to create new tables for phpMyAdmin.

mysql < /usr/share/phpMyAdmin/sql/create_tables.sql -u root -p

Create a virtual host file for phpMyAdmin (Ex. ) under directory.

vi /etc/nginx/conf.d/phpMyAdmin.conf

Paste the following content into the above file. Change the domain name as per your requirement.

server {
   listen 80;
   server_name ;
   root ;

   location / {
      index index.php;
   }

## Images and static content is treated different
   location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
      access_log off;
      expires 30d;
   }

   location ~ /\.ht {
      deny all;
   }

   location ~ /(libraries|setup/frames|setup/libs) {
      deny all;
      return 404;
   }

   location ~ \.php$ {
      include /etc/nginx/fastcgi_params;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
   }
}

Create a tmp directory for phpMyAdmin and change the permission.

mkdir /usr/share/phpMyAdmin/tmp

chmod 777 /usr/share/phpMyAdmin/tmp

Set the ownership of the phpMyAdmin directory, as shown below.

chown -R apache:apache /usr/share/phpMyAdmin

Restart the services.

systemctl restart nginx 

systemctl restart php-fpm

Add a firewall rule to allow HTTP requests from the external network.

firewall-cmd --permanent --add-service=http

firewall-cmd --reload

Access the phpMyAdmin using the browser by going to the below URL.

Log in as the DB root or a regular database user.

Install phpMyAdmin with Nginx on RHEL 8 – phpMyAdmin Login Page
Install phpMyAdmin with Nginx on RHEL 8 – phpMyAdmin Login Page

You will get the home page where you can manage databases.

Install phpMyAdmin with Nginx on RHEL 8 - phpMyAdmin Main Page
Install phpMyAdmin with Nginx on RHEL 8 – phpMyAdmin Main Page

I hope this post helped you to install phpMyAdmin with Nginx on CentOS 8 / RHEL 8. Please share your feedback in the comments section.