How to Install PhpMyAdmin with Apache in RHEL Systems

In this article, we’ll walk you through the step-by-step process of installing the latest version of PhpMyAdmin with Apache web server on RHEL-based distributions such as CentOS Stream, Fedora, Rocky Linux, and Alma Linux.

What is PhpMyAdmin?

PhpMyAdmin is a popular and powerful web-based database management tool, and having the latest version ensures you have access to the most up-to-date features and security enhancements. By the end of this guide, you’ll be able to manage your MySQL or MariaDB databases with ease using PhpMyAdmin.


Before we begin, make sure you have the following:

  • Access to a RHEL, CentOS Stream, Fedora, Rocky Linux, or AlmaLinux system.
  • Make sure you can either log in as the root user or have sudo privileges to install software.
  • An existing LAMP stack, which includes Apache, MySQL/MariaDB, and PHP. If you don’t have LAMP, you can follow these steps to set it up.

Step 1: Update the System

Before installing any software, it’s crucial to ensure that your system is up to date by running the following dnf command.

sudo dnf update
Update Linux System
Update Linux System

This will update all the packages on your system to the latest versions.

Step 2: Install Apache Web Server

PhpMyAdmin is a web-based tool, and to use it, you need to install the Apache web server using the following command.

sudo dnf install httpd
Install Apache in Linux
Install Apache in Linux

Once installed, start the Apache service and enable it to start at boot.

sudo systemctl start httpd
sudo systemctl enable httpd

Step 3: Install MariaDB or MySQL

You will also need a database server. You can choose to install either MariaDB or MySQL, but we will go with MariaDB in this example.

sudo dnf install mariadb-server
Install MariaDB in Linux
Install MariaDB in Linux

Once installed, start the MariaDB service and enable it to start at boot.

sudo systemctl start mariadb
sudo systemctl enable mariadb

Next, secure your MariaDB installation by running the script, which will prompt you to enter a password for the root user, disallow remote root logins, and remove anonymous users. It will also remove the test database, which by default can be accessed by anonymous users.

sudo mysql_secure_installation
Secure MariaDB in Linux
Secure MariaDB in Linux

Step 4: Install PHP

PhpMyAdmin is built with PHP, so we need to install PHP and some required extensions using the following command.

sudo dnf install php php-mysqlnd php-json php-mbstring
Install PHP in Linux
Install PHP in Linux

Step 5: Install PhpMyAdmin

Now, let’s proceed with installing PhpMyAdmin on our Linux system by navigating to the web server’s document root directory /var/www/html as shown.

cd /var/www/html

Next, download the latest version of PhpMyAdmin using the following wget command as shown.

sudo wget

Once downloaded, extract the downloaded archive and rename the directory for convenience.

sudo tar -xvzf phpMyAdmin-latest-all-languages.tar.gz
sudo mv phpMyAdmin-*/ phpmyadmin

Create a configuration file for PhpMyAdmin.

sudo cp /var/www/html/phpmyadmin/ /var/www/html/phpmyadmin/

Edit the configuration file:

sudo nano /var/www/html/phpmyadmin/

Find the following line and set your own blowfish_secret:

$cfg['blowfish_secret'] = 'your_secret';

Save and exit the file.

Step 6: Open Apache Port in firewalld

By default, Apache commonly uses ports 80 and 443 for HTTP and HTTPS, respectively. To open Apache ports and allow access to PhpMyAdmin on your server, run:

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --reload

These commands add a rule to allow incoming traffic on the specified port and reload the firewall to apply the changes.

Step 7: Restart Apache Web Server

Finally, restart Apache to apply the changes:

sudo systemctl restart httpd

Step 8: Access PhpMyAdmin

You can now access PhpMyAdmin through your web browser by navigating to your server’s IP address or domain name followed by “/phpmyadmin” in the URL:


Log in using your MySQL or MariaDB credentials.

PHPMyAdmin Login
PHPMyAdmin Login
PHPMyAdmin Dashboard
PHPMyAdmin Dashboard

Step 9: Allow External Access in PhpMyAdmin

Open the PhpMyAdmin configuration file.

sudo vi /etc/httpd/conf/httpd.conf

Find the <Directory "/var/www/html"> section or the section where your PhpMyAdmin is configured and updates the Require directive to allow all IP addresses to access PhpMyAdmin.

<Directory "/var/www/html/phpmyadmin">
    Require all granted

The above configuration allows access from any IP address, but if you want to restrict access to specific IPs, replace Require all granted with Require ip your_ip.

Restart Apache to apply the changes.

sudo systemctl restart httpd

Now, you should be able to access PhpMyAdmin from the outside world using your server’s IP address or domain.


Remember, opening access to PhpMyAdmin from the outside world can pose security risks. Make sure that you have a strong authentication mechanism in place and consider using HTTPS for encrypted communication. Additionally, restrict access to only trusted IP addresses if possible or secure PhpMyAdmin login URL.

Change phpMyAdmin Login URL

The default login URL for phpMyAdmin is predictable and commonly targeted by malicious actors attempting to exploit vulnerabilities. Changing the login URL adds an additional layer of security, making it more difficult for unauthorized users to gain access to your database management interface.

To do so, create a /etc/httpd/conf.d/phpMyAdmin.conf configuration file.

vi /etc/httpd/conf.d/phpMyAdmin.conf

Next, add the following configuration.

#Alias /phpMyAdmin /var/www/html/phpmyadmin
Alias /my /var/www/html/phpmyadmin

<Directory /var/www/htm/lphpmyadmin>
    AddDefaultCharset UTF-8

    <IfModule mod_authz_core.c>
        # Apache 2.4
            Require all granted
            # Additional IP or hostname-based access control can be added here

    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order Deny,Allow
        Deny from All
        Allow from
        Allow from ::1
        # Additional IP or hostname-based access control can be added here


Replace /my with your desired custom login URL. Save the changes and exit the text editor.

After making changes to the configuration files, restart Apache to apply the modifications:

systemctl restart httpd

Open your web browser and navigate to the new phpMyAdmin login URL.
phpMyAdmin Login URL
phpMyAdmin Login URL

Setting Up SSL for phpMyAdmin

Securing the communication between the Apache web server and phpMyAdmin is crucial to protect sensitive information such as login credentials and database content. One effective way to achieve this is by configuring SSL (Secure Socket Layer) for phpMyAdmin on an Apache web server.

To do so, first install the mod_ssl module on your server.

yum install httpd mod_ssl openssl

Next, create a directory to store the certificate and generate a self-signed SSL certificate and private key as shown.

mkdir /etc/httpd/ssl 
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt
Create SSL Certificate for PhpMyAdmin
Create SSL Certificate for PhpMyAdmin

After creating the SSL certificate and key, open the Apache SSL configuration file.

vi /etc/httpd/conf.d/ssl.conf

Next, add the following lines to the configuration file.

SSLEngine on
SSLCertificateFile /etc/httpd/ssl/apache.crt
SSLCertificateKeyFile /etc/httpd/ssl/apache.key

Save the changes and restart the Apache web server.

systemctl restart httpd

Now, open the phpMyAdmin configuration file.

vi /var/www/html/phpmyadmin/

Add the following lines to force SSL for phpMyAdmin.

$cfg['ForceSSL'] = true;

Save the changes and exit the text editor.

Finally, open your web browser and navigate to the following URL to access phpMyAdmin over a secure SSL connection.

Kindly be aware that the message indicating an insecure connection is solely due to the utilization of a self-signed certificate. To proceed, click on “Advanced” and affirm the security exception.

SSL Warning
SSL Warning
Secure phpMyAdmin Login
Secure phpMyAdmin Login

Congratulations! You’ve successfully installed PhpMyAdmin with Apache on your RHEL, CentOS Stream, Rocky Linux, or AlmaLinux system. This web-based tool simplifies the management of your databases, making tasks like database creation, queries, and data management a breeze.

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

55 thoughts on “How to Install PhpMyAdmin with Apache in RHEL Systems”

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.