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: 
    wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
  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>
        ServerAdmin manyrootsofallevil@myhost.com
        DocumentRoot /var/www/html
        ServerName  Joomla
        ErrorLog logs/Joomla_error
        CustomLog logs/Joomla-access_log common
    </VirtualHost>

    <VirtualHost *:8888>
        ServerAdmin manyrootsofallevil@myhost.com
        DocumentRoot /var/www/phpMyAdmin
        ServerName  Joomla
        ErrorLog logs/phpMyAdmin_error
        CustomLog logs/phpMyAdmin-access_log common
    </VirtualHost>
    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 (config.inc.php) and copy it to /var/www/phpMyAdmin.
  15. You can now start using phpMyAdmin on http://192.168.1.65:8888

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.

10 comments:

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

    ReplyDelete
  2. I have posted you in my blog:

    http://golpeandoelteclado.blogspot.com/2012/02/instalando-phpmyadmin-en-centos-62.html

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

    ReplyDelete
  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?

    ReplyDelete
  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?

    ReplyDelete
    Replies
    1. which php file are you referring to?

      The config.inc.php file?

      Delete
  6. Excellent article!!

    Thank you

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. 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

    ReplyDelete