Image: iStock/GaudiLab

If you’re a database administrator, and you have to manage either MySQL or MariaDB on your data center servers, you know the benefit of having a good GUI to make the task a bit more efficient. And if your servers have migrated from CentOS to Rocky Linux, you might be a bit worried about getting such a GUI up and running. Fret not. There’s always phpMyAdmin.

The problem with phpMyAdmin is that the installation on Rocky Linux (and most RHEL clones) isn’t nearly as straightforward as it is with Ubuntu. But I’m going to help you out with that. Once you’ve walked through this tutorial, you’ll have phpMyAdmin up and running in minutes.

Are you ready?

SEE: Kubernetes: A cheat sheet (free PDF) (TechRepublic)

What you’ll need

To get phpMyAdmin installed, you’ll need a running instance of Rocky Linux and a user with sudo privileges. That’s it. Let’s get to work.

How to install Apache and MySQL

Before you install the web and database server, make sure to update Rocky Linux with:

sudo dnf update -y

After the update completes, reboot (if the kernel is updated) and then install the webserver with:

sudo dnf install httpd -y

Start and enable the webserver 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 enable MySQL:

sudo systemctl start mysqld
sudo systemctl enable mysqld

Secure the database installation with:

mysql_secure_installation

How to install PHP

We now need to install PHP, which is done in a much different manner than it is on Ubuntu. First, 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

Now we can install PHP and the various modules required 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 unpack phpMyAdmin

Next, we’ll download the phpMyAdmin file with the command:

wget https://files.phpmyadmin.net/phpMyAdmin/5.1.1/phpMyAdmin-5.1.1-all-languages.zip

Make sure to check the official download page to ensure you’re downloading the most recent version.

Unpack the file with:

unzip phpMyAdmin-*-all-languages.zip

If unzip isn’t 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 trick, we’ll configure phpMyAdmin. Change into the phpmyadmin directory with:

cd /usr/share/phpmyadmin

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 resultant string.

Open the phpMyAdmin configuration file with the command:

sudo nano config.inc.php

In that file, look for the line:

$cfg['blowfish_secret'] = '';

Paste the 32-bit secret string between the two single quotes.

Scroll down to the Directories for saving/loading files from sever section and add the following line:

$cfg['TempDir'] = '/tmp';

Save and close the file.

Create a new tmp directory and give the everything the necessary permissions/ownership 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 config file

Our next step is to create an Apache config file with the command:

sudo nano /etc/httpd/conf.d/phpmyadmin.conf

In that 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 set the SELinux policies

In order for SELinux to allow traffic to the alternative location (/usr/share/phpmyadmin), we need to make it aware. To do that, issue 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 for the login credentials.

Congratulations, you’ve just installed phpMyAdmin on Rocky Linux, for easier MySQL database administration.

Subscribe to the Data Insider Newsletter

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more. Delivered Mondays and Thursdays

Subscribe to the Data Insider Newsletter

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more. Delivered Mondays and Thursdays