How To Install phpMyAdmin with Apache on CentOS 7 / RHEL 7
phpMyAdmin is the web-based administration tool for managing the MySQL and MariaDB servers. It helps in performing databases activities such as creating, deleting, querying, tables, columns, relations, indexes, users, permissions, etc.
This guide will help you to install phpMyAdmin with Apache on CentOS 7 / RHEL 7.
Prerequisites
In this guide, I will use PHP 7.3 for phpMyAdmin.
Install MySQL / MariaDB Server
Before installing phpMyAdmin, install a database instance on your system to connect. You could install it as a standalone database or install as part of the LAMP stack.
Install the database and then required packages shown below.
Standalone Database
READ: How To Install MariaDB on CentOS 7 / RHEL 7
yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm yum install --enablerepo=remi-php73 -y httpd php php-cli php-mysqlnd
LAMP Stack
READ: How To Install LAMP Stack on CentOS 7 / RHEL 7
Install phpMyAdmin
phpMyAdmin is available in EPEL. So, install EPEL repository rpm to configure EPEL repository on your system.
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Install phpMyAdmin using the following command.
yum install -y --enablerepo=remi-php73 phpmyadmin
Configure phpMyAdmin
phpMyAdmin places the configuration files in /etc/httpd/conf.d directory. It has rules and permission for the access.
By default, phpMyAdmin can be accessed only from the localhost. To access phpMyadmin from external machines, we have to edit the phpMyAdmin.conf file.
vi /etc/httpd/conf.d/phpMyAdmin.conf
In CentOS 7, web access is managed by the mod_authz_core.c module. So, the allow or deny rules won’t work even if you modify.
Default config will look like below.
# phpMyAdmin - Web based MySQL browser written in php # # Allows only localhost by default # # But allowing phpMyAdmin to anyone other than localhost should be considered # dangerous unless properly secured by SSL Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /phpmyadmin /usr/share/phpMyAdmin <Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8 <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require ip 127.0.0.1 Require ip ::1 </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory> <Directory /usr/share/phpMyAdmin/setup/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require ip 127.0.0.1 Require ip ::1 </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory>
Please comment out Require ip 127.0.0.1 and Require ip ::1 then add Require all granted just below to commented line. The content will look like below after the modification.
# phpMyAdmin - Web based MySQL browser written in php # # Allows only localhost by default # # But allowing phpMyAdmin to anyone other than localhost should be considered # dangerous unless properly secured by SSL Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /phpmyadmin /usr/share/phpMyAdmin <Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8 <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> # Require ip 127.0.0.1 # Require ip ::1 Require all granted </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory> <Directory /usr/share/phpMyAdmin/setup/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> # Require ip 127.0.0.1 # Require ip ::1 Require all granted </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory>
Restart the Apache service.
systemctl restart httpd
Firewall
Configure the firewall to allow HTTP requests from external networks.
firewall-cmd --permanent --add-service=http firewall-cmd --reload
Access phpMyAdmin
Now access the phpMyAdmin from the browser, URL will be:
OR
Login with the root (DB admin) or any database user.

You will get the database page.

Conclusion
That’s All. I hope you have learned how to install phpMyAdmin with Apache on CentOS 7 / RHEL 7. Please share you feedback in the comments section.