Install and Configure phpMyAdmin on CentOS

In this post, we will guide how to install and configure phpMyAdmin on a CentOS 6.x VPS. The procedure should be fairly similar for other versions.

Step 1: Turn on EPEL repo :

phpMyAdmin package is not included in default RHEL / CentOS repositories. So turn on EPEL repo as follows:

cd /tmp
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm

Step 2: Install phpMyAdmin on a CentOS / RHEL Linux :

Type the following yum command to download and install phpMyAdmin:

yum search phpmyadmin
yum -y install phpmyadmin

Step 3 :Install MySQL server on a CentOS/RHEL :

To use phpMyAdmin, We need database software, we will install MySQL and preform some initial configuration from the command line:

yum install mysql-server mysql

Turn on and start the MySQL service, type:

chkconfig mysqld on
service mysqld start

We can configure some necessary directory structures and create some management system tables with the following command:

mysql_install_db

Start secure MySQL installation by running the following command:

mysql_secure_installation

You will be asked a number of questions:

  • Enter current password for root: press Enter
  • Set root password? Y
    • New password: Type an administrative password here
    • Re-enter new password: Confirm the password
  • Remove anonymous users? Y
  • Disallow root login remotely? Y
  • Remove test database and access to it? Y
  • Reload privilege tables now? Y

Your MySQL installation should be up and running. Now test that you can log in with the password you set by typing:

mysql -u root -p
Enter password:

Type exit to return to the shell prompt:

exit

Step 4: Configure phpMyAdmin :

You need to edit /etc/httpd/conf.d/phpMyAdmin.conf file, enter:

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

It allows only localhost by default. Find line that read follows:

Require ip 127.0.0.1,There should be four locations that you need to change.

. . .
Require ip your_workstation_IP_address
. . .
Allow from your_workstation_IP_address
. . .
Require ip your_workstation_IP_address
. . .
Allow from your_workstation_IP_address
. . .

Save and close the file. Restart Apache / httpd server:

service httpd restart

Open a web browser and type the following url:

https://your-server-ip/phpMyAdmin/

OR
http://your-server-ip/phpMyAdmin/

You will be asked to log in. Use the user root and the password that you selected during the MySQL configuration stage. phpMyAdmin configuration file is located at /etc/phpMyAdmin/config.inc.php. You can edit this file using :

vi /etc/phpMyAdmin/config.inc.php

Congratulations, you are done.