Child pages
  • Installing phpMyAdmin on CentOS 7
Skip to end of metadata
Go to start of metadata
Note: This how-to assumes that your CentOS 7 server already has a LAMP stack (web server) configured on it. For a how-to on how to setup a LAMP stack, please see Configuring a Basic LAMP Stack on CentOS 7.

Introduction

phpMyAdmin is a program that you can install on your server to make working with MySQL databases easier, done through an easy-to-use GUI that you can access remotely on your server.

Step one: Install EPEL repository

Before we can install phpMyAdmin, we must first install the EPEL repository. The EPEL repository contains useful software packages that are not contained in the default installation of CentOS 7. There are two ways to install the EPEL repository, both of which I will explain below:

Method 1:

This is the easiest and quickest method of the two. However, it isn’t always an option, hence why there is a second option as well.

To install the EPEL repository, simply run the following command:

sudo yum -y install epel-release
sudo yum -y update

It’s as easy as that! The EPEL repository is now installed.

Method 2:

This method involves installing the package manually via the rpm command. For CentOS 7, run the following command:

sudo rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
sudo yum -y update

The above command will download the official EPEL .rpm package, and will install it using the rpm package utility. Once you have run the above command, the EPEL repository will be installed.

Step two: Install phpMyAdmin

Installing phpMyAdmin is very easy now that the EPEL repo is installed. Simply run the following command:

sudo yum -y install phpmyadmin

The above command will install phpmyadmin. However, if you browse to http://your_ip_here/phpmyadmin you’ll be presented with a 403 forbidden error, stating that you do not have access to this directory. In order to access phpMyAdmin you will need to edit the phpMyAdmin configuration file to allow you to access it from your IP address.

Note: This is a security feature to prevent attackers from brute forcing their way through the phpMyAdmin login screen.

 

First, obtain your IP address. This can be done by going to google.com and typing “IP” into the search bar. You should see your IP address there at the top.

Once you have that, you’ll need to open the phpMyAdmin.conf file.

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

Once you have it open, search for the following 4 lines:

Require ip 127.0.0.1

Allow from 127.0.0.1

Require ip 127.0.0.1

Allow from 127.0.0.1

 

Below each of these lines, add an identical line, but replace “127.0.0.1” with the IP address that you got from google search. Example:

 

Require ip 60.70.80.90

Allow from 60.70.80.90

etc…

Once you have made the changes, save them, then restart Apache:

sudo systemctl restart httpd

Now when you browse to http://your_ip_here/phpmyadmin you should see the phpMyAdmin login screen. The username and password are the “root” username and password for your MySQL installation.

Conclusion

You’ve now successfully managed to install phpMyAdmin on your server. Using phpMyAdmin, you can quickly and easily create, edit and view MySQL databases on your server. While this guide covered how to install phpMyAdmin, you can find a wealth of additional information in their official documentation, located here: http://docs.phpmyadmin.net/en/latest/.