When it comes to database administration and development, phpMyAdmin is a great free tool that can be used with MariaDB and MySQL. The following instructions will walk you through installing it on an AWS CentOS 8 image.
1. By default, phpMyAdmin is not available in the CentOS 8 default repository. So, you will need to download the latest version of the phpMyAdmin from their official website. You can download it with the following command:
sudo wget https://files.phpmyadmin.net/phpMyAdmin/4.9.2/phpMyAdmin-4.9.2-all-languages.zip
2. Once downloaded, unzip the downloaded file with the following command:
sudo unzip phpMyAdmin-4.9.2-all-languages.zip
3. Next, move the extracted content to the /usr/share directory as shown below:
sudo mv phpMyAdmin-4.9.2-all-languages /usr/share/phpmyadmin
4. Next, change the directory to /usr/share/phpmyadmin and rename the file config.sample.inc.php:
cd /usr/share/phpmyadmin
sudo mv config.sample.inc.php config.inc.php
5. Next, open the file with your vi text editor as shown below:
sudo vi config.inc.php
6. Change the following line adding a password in the single quotes
$cfg[‘blowfish_secret’] = ”;
7. Next, create a tmp directory for phpmyadmin and give proper permissions:
sudo mkdir /usr/share/phpmyadmin/tmp
sudo chown -R apache:apache /usr/share/phpmyadmin
sudo chmod 777 /usr/share/phpmyadmin/tmp
8. Next, you will need to create an Apache virtual host configuration file for phpMyAdmin. You can create it with the following command:
sudo vi /etc/httpd/conf.d/phpmyadmin.conf
9. Add the following to the 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>
10. Save and close the file when you are finished. Then, restart the Apache service with the following command:
sudo systemctl restart httpd
11. By default, SELinux is enabled in CentOS 8. So you will need to configure SELinux for phpMyAdmin to work correctly. First, install the policycoreutils-python-utils package to manage an SELinux environment with the following command:
sudo yum install policycoreutils-python-utils
12. Next, enable access to /usr/share/phpmyadmin directory with the following commands:
sudo semanage fcontext -a -t httpd_sys_rw_content_t ‘/usr/share/phpmyadmin/’
sudo semanage fcontext -a -t httpd_sys_rw_content_t “/usr/share/phpmyadmin/tmp(/.*)?”
13. sudo restorecon -Rv ‘/usr/share/phpmyadmin/’
14. Now check for phpMyAdmin login screen in browser using either of the following:
http://yourdomainname.com/phpmyadmin