How To Install phpMyAdmin with Nginx on CentOS 8 / RHEL 8

0

ADVERTISEMENT

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

THIS DOCUMENT IS ALSO AVAILABLE FOR

Prerequisites

The steps mentioned in this article will only work if you have enabled subscription on RHEL 8 or configured the local yum repository on your system.

Install MySQL / MariaDB Server

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

Standalone Database

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

You can skip the database part in the LEMP stack tutorial if your system already has MariaDB/MySQL database.

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

yum install -y php-json php-mbstring

LEMP Stack

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

Install phpMyAdmin

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.

ADVERTISEMENT

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

Configure 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'] = 'bo95yavJ;V,1PzSlxyFwtyMJ}WmG98-6'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Import the create_tables.sql 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. phpMyAdmin.conf) under /etc/nginx/conf.d 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 pma.itzgeek.local;
   root /usr/share/phpMyAdmin;

   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 /usr/share/phpMyAdmin$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

Firewall

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

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

firewall-cmd --reload

Access phpMyAdmin

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

http://your-fully-qualified-domain-name

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

Conclusion

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

ADVERTISEMENT

You might also like