How to Install and use phpMyAdmin on Rocky Linux

This article will explain how to install and use PhpMyAdmin on Rocky Linux. PhpMyAdmin is the best tool for handling databases like MySQL and MariaDB over the web rather than using them on the command line. Multi-database management can be accomplished with a single software package. With a few clicks, you can create, delete, export, and import databases using a GUI environment. It is a free and open-source application written in PHP that communicates with a remote MySQL server. This tool is commonly used by developers and system administrators to manage databases in both development and production environments, especially among web hosting companies.

Here are some advantages of PHPMyAdmin::

* The tool supports MySQL and MariaDB operations in a wide range.

* Accessible from all Web Browsers and available on all platforms

* The tool is easy to use, lightweight, and robust

* By using this tool, you can create, select, update, and delete databases.

* There is an excellent user interface for almost every feature on MySQL and MariaDB.

* For beginners, this is an advantage since they can operate multiple databases safely with this tool.

* And many more...

Prerequisites :

Operating System       :    Rocky Linux / RHEL /CentOS /Fedora
Packages & Dependencies:    Apache/Nginx Webserver & Standalone Databases like MySQL/MariaDB
User account           :    root user or user account with sudo privileges
Recommended to run all the administrative commands as with sudo privilege instead of root.

Difficulties in setting up sudo users? Click here to find the steps.

For those new to Rocky Linux, you can check the Rocky Linux installation steps by visiting this link.


To install PhpMyAdmin, we will need a working LAMP stack or standalone database MySQL/MariaDB and PHP supported Web Server (Apache/Nginx).

For a better understanding from a beginner's perspective, let's walk through the entire installation process, which includes installing Apache, MariaDB, PHP, then PHPMyAdmin. The course is also intended for those who are already familiar with LAMP stacks and are looking for some assistance. Refer to the following guide: How to Install LAMP Stack.

My Lab Setup :

LAMP Server:

Operating System    :   Rocky Linux release 8.5 (Green Obsidian)
Hostname            :   db01.linuxteck
IP Address          :
Step 1: Install Apache Package

It is always recommended to update your OS first, then follow the rest of the instructions.

$ sudo dnf update


Once your OS has been updated, proceed with installing PHPMyAdmin dependencies.

$ sudo dnf install httpd -y


Start the httpd service with the following commands: Make sure the service starts after every reboot, and verify that it's working.

$ sudo systemctl start httpd


$ sudo systemctl enable httpd


$ sudo systemctl status httpd

how to check the apache status in linux


The output shows Apache has started and is running (active).

Now we need to open up the firewall port for HTTP (80) and HTTPS (443) services. Once this is done, our website will be accessible to the public. Use the following command to do so.

$ sudo firewall-cmd --permanent --add-port=80/tcp


$ sudo firewall-cmd --permanent --add-port=443/tcp


$ sudo firewall-cmd --reload


You can now view all available information for the default zone by using the following command:

For more information on firewalld services, see this article about 15 useful firewall-cmd commands for Linux.

$ sudo firewall-cmd --list-all

Viewing the Current Status and Settings of firewalld


That's it. You can now launch your web browser and enter your server's IP address. Since my IP address is "", just hit enter and the Test Page from Apache will appear. This means that the Apache Server is up and running.

test page for the nginx http server

Step 2: Install MySQL / MariaDB Server


The demonstration uses MariaDB, but you could use MySQL as well. However, MariaDB is a fast, scalable, and reliable database. To install MariaDB, run the following command:

$ sudo dnf install mariadb-server mariadb -y

how to install mariadb in linux command line

After installation is complete, run the following command to start the MariaDB service and have it start upon reboot.

$ sudo systemctl enable mariadb


$ sudo systemctl start mariadb


$ sudo systemctl status mariadb

Start, Stop And Check Status For MariaDB

Due to MariaDB's default security level, it is not suitable for use in production settings. Therefore, you must secure MariaDB. Here is how to secure MariaDB.


Using one of the following commands, you will be able to execute the "mysql_secure_installation" script, to further strengthen the security level of the MariaDB server.

$  sudo mariadb-secure-installation      or           $ sudo mysql_secure_installation


You can utilize the screenshot below for guidance on how to follow the instructions accordingly.

mysql secure installation command not found

mariadb secure installation command not found

mariadb secure installation linux

That's it. Your MariaDB security measurements have now been updated. You can now try logging into MariaDB with the latest password you have entered above for testing purposes.

$ mysql -u root -p

how to login to mariadb from command line

MariaDB's prompt will appear once you successfully log in. Enter "quit" to exit the MariaDB prompt.

Step 3: Install PHP


The PHP package and its dependencies need to be installed now. PHP stands for Hypertext Preprocessor. It is commonly used for server-side scripting language. The application interacts with the database to pull up information and send processed content to our Web Server. As it is open-source and used by many popular CMS like WordPress, Joomla, Magento, etc... PHP-FPM offers additional PHP functionality since version 5.3.3.Compared to CGI methods, PHP-FPM consumes less system resources, especially memory, resulting in better performance.

You can find out which PHP versions are available in the AppStream repository by using the command below.

$ sudo dnf module list php

dnf module list php


As you can see in the list, 3 different versions are available, and PHP 7.2 is the default version of Rocky Linux 8.5; however, the PHP version 7.2 has reached end-of-life status. As such, we can activate the version as needed. I am here to activate version 7.4 of PHP. Type in the following command to activate PHP:

$ sudo dnf module enable php:7.4

dnf module enable php:7.4
Now if you run the same command as before, "sudo dnf module list php", you will see php version 7.4 is enabled.

sudo dnf module list php

Now you can install PHP easily with the following command. Besides installing the main PHP package, it will also install some dependencies of several PHP modules.

$ sudo dnf install php php-cli php-gd php-curl php-zip php-mbstring -y

install PHP and its dependencies modules

Verify the installed PHP version with the following command.

$ php -v

How to check the php version

For the Prerequisites installation of PhpMyAdmin to succeed, you must restart the Apache Web Server in order to make PHP requests in cgi-mode.

$ sudo systemctl restart httpd


The PHP process can now be tested in a web browser with a php fundamental script by creating a sample file called "info.php". The sample file generates tables that summarize its configuration. You should place it in the /var/www/html directory. However, make sure that after using this file, it is deleted from your server since its existence may pose a huge security risk to unauthorized users.

$ sudo vi /var/www/html/info.php

Save and close the file. Enter 'http://youripaddress/info.php' in your web browser. As a result, you will see the complete information about PHP, just like in the screenshot below. You can use PHP info for debugging and to ensure your server's settings are set correctly.

how to run phpinfo in browser

Step 4: Install PHPMyAdmin


For Rocky Linux, the PHPMyAdmin package is not yet available in the OS repository, so we need to download it from the official PHPMyAdmin website, and we are using the latest stable release (5.2.0) at the time of writing this article. You can download the file directly into the "/tmp" directory with the following command.

$ $ sudo wget -P /tmp

Now extract the download tar.gz file from the "/tmp" directory.

$ cd /tmp

$ sudo tar -xvf phpMyAdmin-latest-english.tar.gz

You should now rename and move the extracted "phpMyAdmin-5.2.0-english" directory to "/usr/share/phpmyadmin".

$ sudo mv phpMyAdmin-5.2.0-english /usr/share/phpmyadmin


In order for PHPMyAdmin to recognize this file, we now need to create a customized configuration file for it. By default there will be no configuration file for PHPMyAdmin. The sample configuration file for phpMyAdmin is located inside the phpMyAdmin directory. It can be found in the directory /usr/share/phpmyadmin. Renaming a file is possible, however, it is best to keep a backup copy of the original copy in case of any issue, then you can simply revert or re-create it. The following command can be used to copy the sample content to the new main configuration.

$ cd /usr/share/phpmyadmin/

$ sudo cp


As part of the "" file, we need to generate a 32 bit secret string to add value to the Blowfish Cipher Chain. We need to generate this value before editing the file. The following command will generate the keys for us: "openssl rand". This program will generate random bytes using a cryptographically secure pseudo random number generator (CSPRNG).

$ openssl rand -base64 32





openssl rand base64 32

Now, open the "" and enter the blowfish_secret string and temp directory path into the configuration file. The rest of the default settings will be fine for most use cases. If you need to tweak more, you can do so based on your requirements.

$ sudo vi /usr/share/phpmyadmin/


You need to add the above-generated key to the following line in your configuration file. Please do not use the key I generated, it is just a sample. You must generate and add your own and add according to the instructions above . You should also add the "TempDir" path under the "Directories for saving/loading files from server" section.

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

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


Failure to declare the above temp directory may result in an error and may prevent access to phpMyAdmin.

phpMyAdmin - configuration

phpMyAdmin - configuration

Set up a Temporary Directory for PHPMyAdmin and assign its permissions.

$ sudo mkdir /usr/share/phpmyadmin/tmp


$ sudo chown -R apache:apache /usr/share/phpmyadmin


$ sudo chmod 777 /usr/share/phpmyadmin/tmp

Finally, an Apache configuration file for phpMyAdmin is required to access it through the web interface. It tells Apache where the PHPMyAdmin file is located, as well as how the request should be handled. Hence, simply create a new file with the below command in it and paste the code in the "phpmyadmin.conf" file as well.

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



Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted



<Directory /usr/share/phpmyadmin/setup/>
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted

save and close the file.


Activate the MySQL Firewall Port (3306) service and set the proper permissions for SELinux.

$ sudo firewall-cmd --permanent --add-port=3306/tcp

$ sudo firewall-cmd --reload

You can view the default zone's applicable information using the following command: If you're interested in learning more about firewalld services, have a look at this article on 15 basic useful firewall-cmd commands.

$ sudo firewall-cmd --list-all


The following command can be used if your server has enabled SELinux, otherwise you can ignore it. We strongly recommend that you always enable SELinux because it will protect your server.

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

The final step to gaining access to phpMyAdmin via Web is to restart Apache.

$ sudo systemctl restart httpd


You will now need to open your browser and enter the IP address of your server or your domain name with /phpmyadmin. Upon getting to the login screen of phpMyAdmin, type in the username you created above. You will then be able to manage your entire database via PHPMyAdmin using the MariaDB root account and password. However, in real time, you must create different accounts depending on the requirements. It is recommended that multiple accounts be used for different projects for staging and production.



how to get phpmyadmin login page
how to login to phpmyadmin with username and password

phpmyadmin localhost dashboard


After you log into your PHPMyAdmin account, you may see a notice in the footer that reads "The PHPMyAdmin configuration storage is not yet configured" as shown in the screenshot below. The notifications are triggered automatically since no database was created manually. Use the following steps to solve this problem :

Click the link "Find out why"

phpmyadmin configuration storage is not completely configured

You will then be directed to another page where you can click the "Create" link to generate and configure your storage setup.

phpmyadmin configuration storage

phpmyadmin configuration storage


That's it. We hope this article has helped you understand how to install and use PHPMyAdmin in Rocky Linux step by step. Drop me your feedback/comments. Feel free to share this article with others if you like it.

Support My Work

Thank you for your support and for being a part of my journey, I would be very grateful if you could consider buying me a coffee. The contributions you make will help me to continue to produce quality content and enhance my readers' experience.

Buy Me A Coffee

Thank you for your endless support!


About John Gomez

John Britto Founder & Cheif-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 10+ years of experience in Linux and Open Source technologies.

View all posts by John Gomez →

Leave a Reply

Your email address will not be published.