How To Install phpMyAdmin on CentOS 8

Install phpMyAdmin on CentOS 8

In this tutorial, we will show you how to install phpMyAdmin on CentOS 8. For those of you who didn’t know, phpMyAdmin is a web-based client written in PHP for managing MySQL and MariaDB databases. It provides a user-friendly web interface to access and manage your databases. To ease usage to a wide range of people, phpMyAdmin is being translated into 72 languages and supports both LTR and RTL languages.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation phpMyAdmin on a CentOS 8 server.

Install phpMyAdmin on CentOS 8

Step 1. First of all, make sure that all packages are up to date.

sudo dnf update

Step 2. Installing LAMP Stack.

If you don’t have a LAMP stack already installed on your server, you can follow our guide here. Also, install required PHP modules, run the command below to install other required PHP extensions for phpMyAdmin:

dnf install php-{spl,hash,ctype,json,mbstring,zip,gd,curl,xml,common}

Step 3. Installing phpMyAdmin on CentOS 8.

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

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

Move the phpMyAdmin set up to your desired location:

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

Step 4. Configure phpMyAdmin.

First, copy the sample configuration file:

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

Next, edit the configuration file and add a blowfish secret:

nano /usr/share/phpMyAdmin/config.inc.php
['blowfish_secret'] = 'bo95yavpengenKIMPOIyFwtyMJ}WmG98-6'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Then, 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 the Apache webserver so that phpMyAdmin can be accessed with http://your-ip-adddress/phpmyadmin:

nano /etc/httpd/conf.d/phpMyAdmin.conf

Add the following 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
chown -R apache:apache /usr/share/phpMyAdmin

Restart the service to take change effect:

sudo systemctl restart httpd

Step 5. Configure Firewall for phpMyAdmin.

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

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

Step 6. Accessing phpMyAdmin.

Now open your browser and surf to http://your-ip-address/phpmyadmin and your PHPMyAdmin will ask you for the user and password of your MySQL installation, you can use root as user and the root MySQL password, or any other MySQL user/password. If you are using a firewall, please open port 80 to enable access to the control panel.

Install phpMyAdmin on CentOS 8

Congratulations! You have successfully installed phpMyAdmin. Thanks for using this tutorial for installing phpMyAdmin on CentOS 8 system. For additional help or useful information, we recommend you check the official phpMyAdmin website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!