How To Install phpMyAdmin with Apache on CentOS 8

Channel: Linux
Abstract: mv phpMyAdmin-5.0.1-all-languages /usr/share/phpmyadminThe current phpMyAdmin version is compatible with PHP 7.1 and newer and MySQL 5.5 and newer. Th

The current phpMyAdmin version is compatible with PHP 7.1 and newer and MySQL 5.5 and newer. This tutorial will help you with the installation and configuration of phpMyAdmin on the CentOS 8 Linux system.

Step 1 – Prerequisites

We are assuming you already have installed the MySQL server on CentOS 8 operating system. So just install the other required packages to run and access phpMyAdmin.

sudo dnf install httpd wget unzip
sudo dnf install php php-pdo php-pecl-zip php-json php-mbstring php-mysqlnd

Once the installation finished, enable and start httpd web server.

sudo systemctl enable httpd.service
sudo systemctl start httpd.service
Step 2 – Install phpMyAdmin

Your system is ready for the phpMyAdmin installation. Download the latest phpMyAdmin archive from the official download page, or use the below commands to download phpMyAdmin 5.0.1 on your system.

After downloading extract archive and move to the proper location.

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 /usr/share/phpmyadmin

Then create tmp directory and set the proper permissions.

mkdir /usr/share/phpmyadmin/tmp
chown -R apache:apache /usr/share/phpmyadmin
chmod 777 /usr/share/phpmyadmin/tmp
Step 3 – Configure phpMyAdmin

Now, you need to configure web server to serve phpMyAdmin on network. Create Apache configuration file for phpMyAdmin and edit in text editor:

vi /etc/httpd/conf.d/phpmyadmin.conf

add the below content to file.

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> </Directory> <Directory /usr/share/phpmyadmin/setup/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require all granted </RequireAny> </IfModule> </Directory>1234567891011121314151617181920Alias /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></Directory> <Directory /usr/share/phpmyadmin/setup/>   <IfModule mod_authz_core.c> # Apache 2.4     <RequireAny>       Require all granted     </RequireAny>   </IfModule></Directory>

Save your file and close it. The systems with SELinux enabled needs to set proper permissions to allow SELinux policies

chcon -Rv --type=httpd_sys_content_t /usr/share/phpmyadmin/*

After making all the changes, make sure to start the Apache service to reload all settings.

systemctl restart httpd.service
Step 4 – Adjust Firewall

The systems with enabled firewalls need to allow HTTP service from the firewall. Run the below commands to open a port for the webserver in the firewall.

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
Step 5 – Access phpMyAdmin

All done. You have finished the setup with the phpMyAdmin on CentOS 8 Linux machine. Now access phpMyAdmin with the below IP.

http://your-server-ip/phpmyadmin

Replace your-server-ip with the localhost (for the local machine) for server IP address.

Log in with the username and password used to access MySQL on the command line.

Conclusion

You have successfully configured phpMyAdmin on CentOS 8 system. Let’s disable root user login for the phpMyAdmin for security purposes.

Ref From: tecadmin

Related articles