How to Install PHPMyAdmin on CentOS 6?

By Goutham

February 24, 2017

phpmyadmin

Introduction

PHPMyAdmin is an open source tool used in place of MySQL command with graphical and more intuitive way of performing administration tasks like creating,editing, or deleting databases, and managing users with permissions. In the below article lets see how to install PHPMyAdmin on CentOS server.

Prerequisites

  • I will be working on a Fastwebhost managed CentOS 6.6 server.
  • Initially for your CentOS 6.6 server to run PHPMyAdmin it needs LAMP (Linux, Apache, MySQL, PHP) stack installed.

Now our server is ready for PHPMyAdmin installation. So, all you need to do is follow the below steps.

Step 1 : Get EPEL Repository

First, we'll install the EPEL repository. The EPEL repo (Extra Packages for Enterprise Linux) contains many additional packages, including the phpMyAdmin package we are looking for.

rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Step 2 : Installing PHPMyAdmin on CentOS

Before doing anything, the best practice is to ensure all the packages in the server are up to date.

yum -y update

Now our installation is one command away.

yum -y install phpmyadmin

Step 3 : Know your IP address

To access your PHPMyAdmin we need to know the IP address of our Machine. Refer to sources like 

Whatismyip.com

Step 4 : Open PHPMyAdmin configuration file

Check for PHPMyAdmin configuration file with any of the text editor. You can find that at 

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

This present 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 specify the IP address of your home connection.

Change any lines that read Requireip 127.0.0.1 or Allow from 127.0.0.1 to refer to your home connection's IP address.

  • Requireip Machine IP
  • Allow from Machine IP
  • Requireip Machine IP
  • Allow from Machine IP

Now restart Apache

service httpd restart

With this our PHPMyAdmin is in operational mode.

We can access our interface with the domain name or public IP address followed by /phpMyAdmin, in your web browser and it should look like below image.

http://server_domain_or_IP/phpMyAdmin

PHPMyAdmin Interface

You can login to it with your any MySQL user or MySQL root logins which you gave when installing LAMP.

Step 5 : Securing PHPMyAdmin

This step is optional unless you want to really secure it.

Go to the PHPMyAdmin configuration file again.

vim /etc/httpd/conf.d/phpMyAdmin.conf

Toward the top of the file, you will see two lines that look like the below line, there will be a case sensitive. As both the lines looks similar, one with /PHPMyAdmin and other is /phpmyadmin.

Alias /phpmyadmin /usr/share/phpMyAdmin

These are alias, means we access our site's domain name or IP address, followed by either /phpMyAdmin or /phpmyadmin.

We need to disable these specific aliases and put our custom examples -securelink in that place by removing or commenting out the existing lines.

  • # Alias /phpmyadmin /usr/share/phpMyAdmin
  • Alias /securelink /usr/share/phpMyAdmin

Now restart Apache.

service httpd restart

Accessing with the previous link will give you a (404) file not found error.

So, now we need to access it with the belowURl

http://server_domain_or_IP/securelink

Conclusion

I really hope this article helped you install PHPMyAdmin on CentOS 6 & 7 and as well as securing it and I really appreciate a review on this.

Leave a Reply

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

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Create a website in 3 simple steps

Choose a website template, add features, then customise! - Free Online Website builder.