website links

Tuesday, March 12, 2013

How to Install phpMyAdmin on a Linux Server

Most sysadmins who manage servers running Apache and MySQL with PHP find themselves using phpMyAdmin to assist with the MySQL database.

What is phpMyAdmin?

From the phpMyAdmin website: "phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the World Wide Web. phpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions, etc), while you still have the ability to directly execute any SQL statement."

In this tutorial, I'll show you how to install phpMyAdmin on a LAMP (Linux-Apache-MySQL-PHP) server running CentOS 6.x. For a tutorial on installing and configuring LAMP, see this blog post.

Of course, you can install phpMyAdmin by compiling from source code. This tutorial, however, is based on using yum (Yellow Dog Updater Modified) to complete the installation.

Network Diagram

The Companion Video


One server running CentOS 6.x with the following software installed: Apache 2.x, MySQL 5.x, and PHP 5.x. (The specific versions used in this tutorial are CentOS 6.4, Apache 2.2.15, MySQL 5.1.67-1, and PHP 5.3.3.), The procedures shown here may work with other software versions, but they have not been tested on other versions. The server in this tutorial has been configured with an IP address of and a host name of centos6.soundtraining.local. Your server must have public Internet access, either directly or through a firewall/router. You must have administrative (root) access to the server. You can either perform the following tasks as root (easier, but dangerous) or by using sudo to execute the commands.

I manage my Linux servers remotely from a desktop or laptop computer using a remote terminal session over SSH. If I'm using a Windows-based computer for management, I usually use PuTTY to create the terminal sessions.

Enabling the Repository

phpMyAdmin is not available through the default CentOS 6 repositories (repos), so we need to add the RepoForge (formerly RPMforge) repo (not a bad idea anyway). The new installation procedure for RepoForge is much easier than the old procedure used with RPMforge.

Start by checking your version of CentOS with the following command:
cat /etc/redhat-release

This tutorial is based on CentOS 6.4. If you're running any version of CentOS 6.x or RedHat 6.x, this tutorial should apply to you. It has not been tested on other versions, but may work.

Next, check your system's architecture with the following command:
uname -r

Your system should be running either 32-bit (i686) or 64-bit (x86_64) architecture. If it's anything else, this tutorial probably doesn't apply to you.

Visit to download the appropriate package for your architecture and software version. I find it easiest to right-click on the appropriate version on the page and choose "Copy link address" or "Copy shortcut" (depending on your browser). Then I can type the rpm -Uvh command and paste the shortcut into the command-line interface. Alternatively, you can manually type the entire command, as follows:

On x86_64 systems:
rpm- Uvh

On i686 systems:
rpm -Uvh

Now, install phpMyAdmin:
yum install phpmyadmin

You must also configure phpMyAdmin to allow connections from IP addresses other than localhost ( by modifying /etc/httpd/conf.d/phpmyadmin.conf. Use vi or another text editor:

vi /etc/httpd/conf.d/phpmyadmin.conf

Modify the file to add the IP address of your management workstation, in this case

I've read other tutorials that suggest commenting out the entire <Directory /usr/share/phpmyadmin> section to allow any host to connect from any IP address. Do NOT do that. Doing so opens your database to myriad types of attacks from anywhere on the Internet. If you need to use phpMyAdmin from a computer with a dynamically assigned IP address, plan on SSHing into your server to modify the above setting every time your IP address changes. (Changing the above setting requires an httpd restart.)

You must also modify the authentication type for phpMyAdmin by editing  /usr/share/phpmyadmin/

vi /usr/share/phpmyadmin/

Change the authentication type from 'cookie' to 'http':

Restart the Apache server:
service httpd restart

Point the browser on your management workstation to You should receive an authentication request:

Use the username root and the MySQL root password to authenticate.

Even though you have restricted access to phpMyAdmin to a single IP address, you might also want to use a different MySQL account for logins instead of root. You can use phpMyAdmin to set up a new user and grant specific permissions for that user.

For More Linux Configuration Information

Pick up a copy of my configuration guide The Accidental Administrator: Linux Server Step-by-Step Configuration Guide or my Linux command reference Tweeting Linux: 140 Linux Configuration Commands Explained in 140 Characters or Less, both available through Amazon and other resellers.

Please Leave a Comment

If you find this tutorial helpful or if you notice something that needs to be corrected, please leave a comment.

No comments: