How to install phpMyAdmin on Rocky Linux
Databases are considerably easier to manage from a graphical interface. If you have migrated your servers from CentOS to Rocky Linux, you might want to install phpMyAdmin. Jack Wallen shows you how.
If you are a database administrator and need to manage MySQL or MariaDB on your datacenter servers, you know the benefit of having a good graphical interface to make the job a little more efficient. And if your servers have migrated from CentOS to Rocky Linux, you might be a little worried about setting up such a GUI. Do not worry. There is always phpMyAdmin.
The problem with phpMyAdmin is that installing on Rocky Linux (and most RHEL clones) is not as easy as with Ubuntu. But I’ll help you with that. Once you have gone through this tutorial, phpMyAdmin will be up and running in a matter of minutes.
Are you ready?
SEE: Kubernetes: A Cheat Sheet (Free PDF) (TechRepublic)
What you will need
To install phpMyAdmin you will need a running Rocky Linux instance and a user with sudo privileges. That’s it. Let’s get to work.
How to install Apache and MySQL
Before installing the web and database server, be sure to update Rocky Linux with:
sudo dnf update -y
After the update is complete, reboot (if the kernel is updated), then install the web server with:
sudo dnf install httpd -y
Start and activate the web server with:
sudo systemctl start httpd sudo systemctl enable httpd
Next, we need to allow HTTP services through the firewall with the following commands:
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
Now we can install the database with:
sudo dnf install mysql-server mysql -y
Start and activate MySQL:
sudo systemctl start mysqld sudo systemctl enable mysqld
Secure the database installation with:
How to install PHP
Now we need to install PHP, which is done in a very different way than Ubuntu. First of all, let’s reset the php module with:
sudo dnf module reset php
Now we can enable PHP 7.4 with:
sudo dnf module enable php:7.4
We can now install PHP and the various modules necessary for phpMyAdmin with:
sudo dnf install php php-common php-opcache php-cli php-gd php-curl php-mysqlnd php-xml -y
How to download and unzip phpMyAdmin
Then we will download the phpMyAdmin file with the command:
Make sure to check the official download page to make sure you are downloading the most recent version.
Unzip the file with:
If unzip is not installed, install it with:
sudo dnf install unzip -y
Move and rename the newly created directory with:
sudo mv phpMyAdmin-*-all-languages /usr/share/phpmyadmin
How to configure phpMyAdmin
For our next tip, we’ll configure phpMyAdmin. Navigate to the phpmyadmin directory with:
Copy the sample configuration file with the command:
sudo mv config.sample.inc.php config.inc.php
Now we need to generate a 32 bit secret string with:
openssl rand -base64 32
Copy the resulting string.
Open the phpMyAdmin configuration file with the command:
sudo nano config.inc.php
In that file, find the line:
$cfg['blowfish_secret'] = '';
Paste the 32-bit secret string between the two single quotes.
Scroll down to the Directories for saving / uploading files from server section and add the following line:
$cfg['TempDir'] = '/tmp';
Save and close the file.
Create a new tmp directory and give all the necessary permissions / properties with the following commands:
sudo mkdir /usr/share/phpmyadmin/tmp sudo chown -R apache:apache /usr/share/phpmyadmin sudo chmod 777 /usr/share/phpmyadmin/tmp
How to create an Apache configuration file
Our next step is to create an Apache configuration file with the command:
sudo nano /etc/httpd/conf.d/phpmyadmin.conf
In this file, paste the following:
Alias /phpmyadmin /usr/share/phpmyadmin
AddDefaultCharset UTF-8 # Apache 2.4 Require all granted # Apache 2.4 Require all granted
Save and close the file.
How to define SELinux policies
In order for SELinux to allow traffic to the alternate location (/ usr / share / phpmyadmin), we need to signal it. To do this, run the command:
sudo chcon -Rv --type=httpd_sys_content_t /usr/share/phpmyadmin/*
Restart Apache with the command:
sudo systemctl restart httpd
How to access the phpMyAdmin web interface
Everything should now be ready to go. Open a web browser and point it to http: // SERVER / phpmyadmin (where SERVER is the IP address of your hosting server) and you should be prompted to enter the connection information.
Congratulations, you have just installed phpMyAdmin on Rocky Linux, for easier administration of the MySQL database.