How To Install phpMyAdmin With Apache on CentOS 8 / RHEL 8 | Holhol24

25

phpMyAdmin is an open-source, web-based administration tool for managing the MySQL and MariaDB servers. It is one of the most popular database administration tools used by hosting companies and system administrators for performing database activities such as creating, deleting, querying, tables, columns, relations, indexes, users, permissions, etc.

phpMyAdmin is a portable web application written in PHP. It is released under GNU GPL v2.

In this post, we will see how to install phpMyAdmin with Apache on CentOS 8 / RHEL 8.

Prerequisites

Install MySQL / MariaDB Server

Before installing phpMyAdmin, you must have one database instance (MySQL or MariaDB) running on your system to connect. It could be a standalone database instance or installed as part of the LAMP stack.

Standalone Database

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

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

Install PHP, MySQL support package for PHP, and other PHP packages on your system for phpMyAdmin to connect with the database.

yum install -y wget php php-pdo php-pecl-zip php-json php-common php-fpm php-mbstring php-cli php-mysqlnd

LAMP Stack

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

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

yum install -y php-json php-mbstring

Install phpMyAdmin

phpMyAdmin package is not yet available in the OS repository for CentOS 8 / RHEL 8. So, we need to download it from the official website.

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

Install phpMyAdmin using the following command.

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

Move the phpMyAdmin set up to your desired location.

mv phpMyAdmin-4.9.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 a blowfish secret.

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

Generate blowfish secret and place it into 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 

Create an alias in the Apache web server so that phpMyAdmin can be accessed with http://your-ip-add-dress/phpmyadmin.

vi /etc/httpd/conf.d/phpMyAdmin.conf

Copy and paste the below content to the above file.

Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin


   AddDefaultCharset UTF-8

   
     # Apache 2.4
      
      Require all granted
     
   
   
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   



   
     # Apache 2.4
     
       Require all granted
     
   
   
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1
     Allow from ::1
   

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 phpMyAdmin as shown below.

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

Restart the service.

systemctl restart httpd

SELinux

Create SELinux policies for phpMyAdmin to work correctly.

yum install -y policycoreutils-python-utils

semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/phpMyAdmin/'

semanage fcontext -a -t httpd_sys_rw_content_t "/usr/share/phpMyAdmin/tmp(/.*)?"

restorecon -Rv '/usr/share/phpMyAdmin/'

Firewall

Create a firewall rule to allow HTTP requests from external networks.

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

firewall-cmd --reload

Important Notes

Read the important notes before accessing phpMyAdmin with root or regular database users.

MySQL 8.x

MySQL 8.0 installed from MySQL Dev Community repository uses a caching_sha2_password mechanism for authentication which prevents legacy application to access databases including phpMyAdmin at this moment. In simple terms, you won’t be login to phpMyAdmin unless we disable this new password mechanism.

You can globally disable the new password mechanism by placing default-authentication-plugin=mysql_native_password in /etc/my.cnf (Users created after this change will have mysql_native_password authentication mechanism) or you can revert to the old native authentication (mysql_native_password) for individual users (Ex: root) by running ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘’; command in MySQL terminal.

Access phpMyAdmin

Now access the phpMyAdmin from the browser, URL will be:

http://localhost/phpMyAdmin

OR

http://your-ip-addr-ess/phpMyAdmin

Login with the root (DB admin) or any database user.

Install phpMyAdmin with Apache on CentOS 8 – phpMyAdmin Login Page

You will get the database page where you can perform all database activities.

Install phpMyAdmin with Apache on CentOS 8 - phpMyAdmin Home How To Install phpMyAdmin With Apache on CentOS 8 / RHEL 8 | Holhol24 How To Install phpMyAdmin With Apache on CentOS 8 / RHEL 8 | Holhol24 1605831575 92 How To Install phpMyAdmin With Apache on CentOS 8
Install phpMyAdmin with Apache on CentOS 8 – phpMyAdmin Home

Conclusion

I hope you have learned how to install phpMyAdmin on with Apache CentOS 8 / RHEL 8 to manage MariaDB and MySQL database. In addition to this, you can take a look at how to secure your phpMyAdmin installation.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More