PhpMyAdmin is a free and open source administration tool for MySQL and MariaDB. As a portable web application written primarily in PHP, it has become one of the most popular MySQL/Mariadb administration tools, especially for web hosting services. So, if you want to manage and create your databases from web interface you need to install PHPMyAdmin.
This article assume that you have already installed LAMP stack on your machine. If you did not install LAMP use below link to install LAMP on CENTOS 8.
https://unixcop.com/how-to-install-lamp-on-centos-8
Download and extract PHPMyAdmin package
dnf install zip unzip -y
cd /usr/share/
wget https://files.phpmyadmin.net/phpMyAdmin/5.0.1/phpMyAdmin-5.0.1-all-languages.zip
unzip phpMyAdmin-5.0.1-all-languages.zip
mv phpMyAdmin-5.0.1-all-languages phpmyadmin
Now create tmp directory and set the appropriate permissions for phpmyadmin directory using below commands.
mkdir /usr/share/phpmyadmin/tmp
chown -R apache:apache /usr/share/phpmyadmin
chmod 777 /usr/share/phpmyadmin/tmp
Next, edit the config.sample.inc.php file using below commands
cd /usr/share/phpmyadmin
cp config.sample.inc.php config.inc.php
vi config.inc.php
Now find below line and enter root password in quotes
$cfg[‘blowfish_secret’] = ‘your-secure-password’;
also add below lines for caching in same file.
$cfg[‘TempDir’] = ‘/tmp/’;
then save changes to file and exit
After that we need to configure Apache for PHPMyAdmin so that it can be accessible. use below command to edit its configuration file.
vi /etc/httpd/conf.d/phpmyadmin.conf
and add below lines in this file.
<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>
Finally save changes to file and exit.
Restart Apache web server
systemctl restart httpd
Now open your web browser and type below URL, do not forget to replace your server ip address. You should see similar page
http://SERVER-IP/phpmyadmin
Enter your login information to login PHPMyAdmin.
That’s it you have installed PHPMyAdmin on CentOS successfully.