How to Install phpMyAdmin on CentOS
Table of Contents
My Experience Installing phpMyAdmin on CentOS
I set up phpMyAdmin on CentOS for the first time when I inherited a client’s VPS that had MySQL running but no graphical interface. The client’s team were not comfortable with the command line, so they needed a web UI to do routine tasks like viewing tables, running ad-hoc queries, and importing backups.
The installation itself is two commands, but nobody tells you about the 403 error you will almost certainly hit immediately after. It is caused by Apache’s default phpMyAdmin configuration, which restricts access to localhost only — a perfectly sensible default for a public internet server, but completely opaque if you have never seen it before. I spent an embarrassing amount of time wondering if the installation had silently failed before I found the right config block to edit.
The other thing that caught me: the EPEL repository is required for yum install phpmyadmin to find the package. If you skip that first rpm -iUvh step, yum reports “No package phpmyadmin available” and you assume something is wrong with your CentOS version. It is just a missing repo. Steps below reflect exactly the sequence that worked for me.
What is PhpMyAdmin?
PhpMyAdmin is one of the most popular applications for MySQL databases management. It is a free tool written in PHP. Through this software you can create, alter, drop, delete, import and export MySQL database tables. You can run MySQL queries, optimize, repair and check tables, change collation and execute other database management commands. Install PhpMyAdmin isn’t an easy task. You need to do several configuration after installation.
How to install PhpMyAdmin?
$ rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm #Adding repository
$ yum -y update
$ yum -y install phpmyadmin #Install PhpMyAdmin
That’s it. You can start using it by url http:///phpMyAdmin, Ex. http://example.com/phpMyAdmin
Do following changes if you face 403 forbidden issue
$ sudo nano /etc/httpd/conf.d/phpMyAdmin.conf
<Directory /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require all granted
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
In order to reinitialising changes, we need to restart the apache server.
$ sudo apachectl restart #or:
$ /sbin/service httpd restart
I hope that some of this is useful to a few of you. There is always room for an improvements, find out another unix commands and make best use of it. Leave a note in the comments if you have any cool tricks to install PhpMyAdmin. Also checkout my another blog on installing Apache, php and mysql on Ubuntu server.