How to install latest phpMyAdmin on a CentOS 7 server

PhpMyAdmin is a web-based interface for managing MySQL / MariaDB databases that is used as a replacement for command-line utilities. In this article we’re going to show you how to install latest stable version of PhpMyAdmin for Apache on CentOS 7.

To install most recent version of PhpMyAdmin (i.e. 4.7), you need to install and enable EPEL and Remi repositories on your respective Linux distributions as shown:

sudo rpm -Uvh
sudo rpm -Uvh

Once you’ve installed above repositories, now its’ time to install PhpMyAdmin with the help of following command as shown.

yum --enablerepo=remi install phpmyadmin

The installation will now complete. We will need to modify this a bit to get it to work correctly for our installation. Open the file in your text editor now so that we can make a few changes:

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

To change the url of phpMyAdmin, we should remove or comment out the existing lines and add our own:

# Alias /phpMyAdmin /usr/share/phpMyAdmin
# Alias /phpmyadmin /usr/share/phpMyAdmin
Alias /dbmanager /usr/share/phpMyAdmin

In which, dbmanager is up to you.

Currently, this setup is configured to deny access to any connection not being made from the server itself. Since we are working on our server remotely, we need to modify some lines to allow remote connection.

<IfModule mod_authz_core.c>
     # Apache 2.4
     Require all granted

and some more:

<IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Allow,Deny
     Allow from All

Setting up a Web Server Authentication Gate. Within the /usr/share/phpMyAdmin directory block, but outside of any of the blocks inside, we need to add an override directive. It will look like this:

. . .
<Directory /usr/share/phpMyAdmin/>
   AllowOverride All
   <IfModule mod_authz_core.c>
   . . .
. . .

AllowOverride All is the extra line that added.

Our next step is to create the .htaccess file within that directory. Use your text editor to do so now:

sudo nano /usr/share/phpMyAdmin/.htaccess

Within this file, we need to enter the following information:

AuthType Basic
AuthName "Admin Login"
AuthUserFile /etc/httpd/pma_pass
Require valid-user

When you are finished entering this information, save and close the file.

Create the Password File for Authentication

sudo htpasswd -c /etc/httpd/pma_pass username

username is the username that you’d like to use.

If you want to add additional users to authenticate, you can call the same command again without the -c flag, and with a new username:

sudo htpasswd /etc/httpd/pma_pass seconduser

seconduser is the username that you’d like to use.

To implement the changes, restart the web service:

sudo systemctl restart httpd
Leave a reply

Sharing is caring!

Back to Top