Sunday, 22 January 2012

Installing phpMyAdmin in CentOS 6.2 (netinstall)

I really have no issue with using a terminal, in fact I quite love the geekiness associated with it, but for some reason I never feel comfortable using a terminal to manage mySQL, which is why I love phpMyAdmin.

I am installing phpMyAdmin in a machine that hosts Joomla, see this post for more details, in practical terms this means that a second website will be needed to host phpMyAdmin, whether you host this site on a different port or a host header it's up to you, the process is fairly similar. Do bear in mind that using a different port has implications to your firewall configuration, in this post I will be using a different port.

It is worth bearing in mind that this configuration is not secure and as such should only be used on internal networks. Although running the website on a non-standard port will provide obscurity, it does not provide security. Have a look at this post for a secure phpMyAdmin installation guide.

Unfortunately phpMyAdmin is not, at the time of writing, included with RHEL based systems. Luckily, it is part of the Extra Packages for Enterprise Linux (EPEL) interest group. This means that the EPEL repository can be used to install phpMyAdmin thus obviating the need to install it from source.

Here are the steps needed to install phpMyAdmin in a CentOS 6.2 server:
  1. Set SELinux to allow Apache to bind to a non-default port:
    setsebool -P allow_ypbind 1
  2. Download EPEL Release to enable usage of EPEL Repository: 
  3. Install EPEL Release package:
    yum install epel-release-6-5.noarch.rpm -y
  4. Install phpMyAdmin:
    yum install phpmyadmin -y
  5. Create new directory to host the phpMyAdmin website: 
    mkdir /var/www/phpMyAdmin
  6. Copy phpMyAdmin installation to the directory created in the previous step: 
    cp -r /usr/share/phpMyAdmin/. /var/www/phpMyAdmin
  7. Add a new virtual host to Apache, by editing the Apache configuration file /etc/httpd/conf/httpd.conf, see this post for more details. Relevant parts of httpd.conf:
    Listen 80
    Listen 8888

    NameVirtualHost *:80
    NameVirtualHost *:8888

    <VirtualHost *:80>
        DocumentRoot /var/www/html
        ServerName  Joomla
        ErrorLog logs/Joomla_error
        CustomLog logs/Joomla-access_log common

    <VirtualHost *:8888>
        DocumentRoot /var/www/phpMyAdmin
        ServerName  Joomla
        ErrorLog logs/phpMyAdmin_error
        CustomLog logs/phpMyAdmin-access_log common
    1. You can check that the apache configuration file is correct by using:
      apachectl -t 
  8. Restart Apache:
    apachectl -k restart or service httpd restart
  9. Open firewall for port 8888 and save IPTables configuration:
    iptables -I INPUT -p tcp --dport 8888 -j ACCEPT; service iptables save
  10. From a browser navigate to http://localhost:8888/setup :
  11. Click New Server. I only changed the name and compression, accepted defaults for everything else:
  12. Go To Authentication Tab. See this link for an overview of the authentication types:
  13. Click Save, which will bring you to the screen below:
  14. Download the configuration file ( and copy it to /var/www/phpMyAdmin.
  15. You can now start using phpMyAdmin on

Note that steps 2 & 3 simply add repository for the EPEL repository to your yum repository collection and install the repository key.

In theory, the setup script should be able to generate the configuration file for you, but I've not been able to get it to work. Instructions can be found here if you are interested.


  1. Thanks!! You have helped me so much!! Very fast, easy and user-friendly :-D

  2. I have posted you in my blog:

  3. I'm glad that you found the article useful

  4. Thank you for this useful information, if you please visit my blog, there should be little information that might be useful, such Lusca Squid: Install High Performance Proxy CentOS 6x

    Whether we can exchange follower FriendConnect with your blog?

  5. Hi,

    Thanks for the details. Every thing works except the php file which is in the /var/www/html/ folder. can you help me further?

    1. which php file are you referring to?

      The file?

  6. Excellent article!!

    Thank you

  7. These facts are really interesting. Few of them were well known for me but many of them were brand new for me too!
    I will print this one out and show to my friends because they will be definitely interested in that. Thanks!

  8. This comment has been removed by the author.

  9. Hello,

    I configure my server with root user, but I can't connect to phpmyadmin (connection refused for this user)
    Can you help me ?

    Thank you