How to Install phpMyAdmin on Rocky Linux 8

Introduction

phpMyAdmin is a free and popular web-based tool to manage MySQL or MariaDB databases.
Instead of running SQL commands on the terminal, you can use phpMyAdmin in your web browser.
In this guide, we will install phpMyAdmin on Rocky Linux 8 and secure the admin portal using .htaccess.

Step 1: Update Your System

Always update Rocky Linux before installing new software.

sudo dnf update -y
sudo reboot

Step 2: Install Apache, PHP, and MySQL

phpMyAdmin needs a web server, PHP, and a database server (MySQL/MariaDB). Install them with:

sudo dnf install httpd php php-mbstring php-zip php-gd php-json php-mysqlnd mariadb-server -y

Start and enable Apache and MariaDB:

sudo systemctl start httpd mariadb
sudo systemctl enable httpd mariadb

Step 3: Enable EPEL Repository

phpMyAdmin is available in the EPEL (Extra Packages for Enterprise Linux) repository.

sudo dnf install epel-release -y

Step 4: Install phpMyAdmin

Now install phpMyAdmin package:

sudo dnf install phpMyAdmin -y

Step 5: Configure Apache for phpMyAdmin

The default configuration file is located at /etc/httpd/conf.d/phpMyAdmin.conf.
By default, it allows access only from localhost (127.0.0.1).
If you want to allow specific IPs, edit the file:

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

Find the lines like:

Require ip 127.0.0.1

Add your system IP (example: 192.168.1.100):

Require ip 127.0.0.1 192.168.1.100

Step 6: Restart Apache

After changes, restart Apache:

sudo systemctl restart httpd

Step 7: Access phpMyAdmin

Now open your browser and go to:

http://server-ip/phpMyAdmin

Login with your MySQL username and password.

Step 8: Secure phpMyAdmin with .htaccess

For extra security, we will add a username and password using .htaccess.

  1. Enable .htaccess in phpMyAdmin config:
  2. sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
    

    Inside the <Directory /usr/share/phpMyAdmin> section, add:

    AllowOverride All
    
  3. Create a password file for Apache:
  4. sudo htpasswd -c /etc/phpmyadmin/.htpasswd adminuser
    

    It will ask you to set a password for adminuser.

  5. Create a .htaccess file inside phpMyAdmin directory:
  6. sudo nano /usr/share/phpMyAdmin/.htaccess
    

    Add the following lines:

    AuthType Basic
    AuthName "Restricted Access"
    AuthUserFile /etc/phpmyadmin/.htpasswd
    Require valid-user
    
  7. Restart Apache:
  8. sudo systemctl restart httpd
    

Now when you access phpMyAdmin, it will first ask for the Apache username and password. After that, you can log in with your MySQL credentials. This gives double protection.

Conclusion

In this guide, we installed phpMyAdmin on Rocky Linux 8, configured Apache, and secured the portal with .htaccess.
This setup is very useful for students and administrators to manage databases safely through a web interface.

Leave a Reply

Your email address will not be published. Required fields are marked *