Install phpMyAdmin with Apache on CentOS 7 - Step by Step Process ?

phpMyAdmin is a best open source, free and web interface based database management tool for managing MySQL and MariaDB. You can manage MySQL databases, user accounts and privileges, import and export data and much more using phpmyadmin interface.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related phpMyAdmin queries.

In this context, we shall look into how to install phpMyAdmin with Apache on CentOS 7.

Main Features of phpMyAdmin:

  • Create, browse, edit, and drop databases, tables, views, columns, and indexes.
  • Display multiple result sets through stored procedures or queries.
  • Create, copy, drop, rename and alter databases, tables, columns and indexes.
  • Maintenance server, databases and tables, with proposals on server configuration.
  • Load text files into tables.

How to Install phpMyAdmin on CentOS ?

Before proceeding with this installation task, ensure that the following requirements are met:

We recommend that you access your phpMyAdmin installation over HTTPS connections to prevent from unnecessary attacks. If your domain is not secure with an SSL/TLS certificate, you can follow this guide to Secure Apache with Let's Encrypt on CentOS.

1. Install phpMyAdmin on CentOS

phpMyAdmin package is not available on CentOS 7 core repositories. So we will install it from EPEL repository. To start installation you need to enable EPEL repository first by below command:

$ sudo yum install epel-release

Once EPEL repository enabled you can install the phpMyAdmin and it’s dependencies with the below command:

$ sudo yum install phpmyadmin

2. Configure phpMyAdmin

At the time of phpMyAdmin installation, created a Apache configuration file automatically. By default, all connections are denied except localhost so you will need to edit config file and add specific IP Addresses.

i. Open the phpMyAdmin config file by below command:

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

ii. Now replace the Require ip with Require ip YOUR_IP_ADDRESS. Where your ip address is your connections ip address. Following is the example after replace:

# Apache 2.4
    Require ip
    Require ip ::1

iii. Save and close file.

iv. Next, you need to restart Apache by typing:

$ sudo systemctl restart httpd

3. Create MySQL User and Set Privileges

You can create a separate mysql user for access from phpMyAdmin web interface. 

i. Login to mysql by below command:

$ sudo mysql

ii. Now, execute below commands to create a new administrative user with strong password and grant appropriate permissions:

mysql> CREATE USER 'newadmin'@'localhost' IDENTIFIED BY 'STRONG-PASSWORD';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'newadmin'@'localhost' WITH GRANT OPTION;

iii. Exit MySQL shell by typing:


How to Access phpMyAdmin ?

You can access the phpMyAdmin interface by open web browser and type your server's public IP address or domain name followed by /phpmyadmin:


Now, Log in to the interface with the administrative username and password which you created on previous step and hit on Go button.

When you log in, you'll see the phpMyAdmin user interface.

How to Secure phpMyAdmin ?

You can add one more security layer to your phpMyAdmin web interface by setting up a basic authentication. We will create password protected directory.

At First, we will create a password file with user using the htpasswd tool that comes with the Apache package. 

We will store the .htpasswd file in /etc/phpmyadmin directory:

$ sudo htpasswd -c /etc/phpmyadmin/.htpasswd newadmin

Here, newadmin is administrative username which we created for access phpMyAdmin interface. You can choose any user name of your choice. 

Once you execute above command it will prompt you to enter password and confirm password as below:

New password:
Re-type new password:
Adding password for user newadmin

Now we will configure Apache to password protect the phpMyAdmin directory and use the .htpasswd file. 

To do it open phpmyadmin.conf by typing :

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

Make changes as following:

<Directory /usr/share/phpmyadmin>
    Options  +FollowSymLinks +Multiviews +Indexes  # change this line
    DirectoryIndex index.php
    # Add new line start
    AllowOverride None
    AuthType basic
    AuthName "Authentication Required"
    AuthUserFile /etc/phpmyadmin/.htpasswd
    Require valid-user
    # Add new line end

After that, Save and close the file. To take effect restart the Apache service by type:

$ sudo systemctl restart httpd

Now, when you access your phpMyAdmin subdirectory, you will be prompt for the additional account name and password that you just configured:


Once you will enter basic authentication details then only you will be taken to the phpMyAdmin login page where you need to enter your MySQL administrative user login credentials.

[Need urgent assistance in fixing phpMyAdmin errors? We can help you. ]

This article covers how to Install phpMyAdmin with Apache on CentOS 7 system. phpMyAdmin is a database utility used for managing MySQL databases through a graphical web-based interface. It can be configured to manage a local database (on the same system), or a remote database (over a network).

To Install EPEL Repository:

1. Get access to the EPEL repository – the Extra Packages for Enterprise Linux, by running the command.

$ sudo yum install -y epel-release

2. Once that operation finishes, it's a good idea to refresh and update the EPEL repository.

$ sudo yum –y update

To Install Apache Web Server:

1. Install Apache on CentOS use the command.

$ yum install httpd -y

2. Verify the status of Apache by running with the command.

$ systemctl status httpd

To install PHPMyAdmin on CentOS, enter the command:

$ sudo yum -y install phpmyadmin

Related Posts