How To Install phpMyAdmin on RHEL 8

0

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 on RHEL 8.

Prerequisites

Install MySQL / MariaDB Server

Before installing phpMyAdmin, you must have one database instance 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 RHEL 8

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

yum install -y 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 RHEL 8

Install below PHP packages for phpMyAdmin to connect with database.

yum install -y php-json php-mbstring

Install phpMyAdmin

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

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

Install phpMyAdmin using the following command.

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

Move the phpMyAdmin set up to your desired location.

mv phpMyAdmin-4.8.5-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 < /usr/share/phpMyAdmin/sql/create_tables.sql -u root -p

Create an alias in 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

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny> 
      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 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>

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

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 on RHEL 8 - phpMyAdmin Login Page
Install phpMyAdmin on RHEL 8 – phpMyAdmin Login Page

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

Install phpMyAdmin on RHEL 8 - phpMyAdmin Dashboard
Install phpMyAdmin on RHEL 8 – phpMyAdmin Dashboard

Conclusion

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

You might also like