Installing phpMyAdmin in CentOS 5.5 on Rackspace Cloud

PhpMyAdmin is a great tool for being able to manage your MySQL database from a GUI. Here is how to install it onto a fresh CentOS 5.5 Server in Rackspace Cloud. PhpMyAdmin requires Apache, PHP, and MySQL to run. This walkthrough will assume a fresh server that has nothing pre-installed. All commands are performed as root

NOTE: This article has become pretty popular in the search engines. This is still an excellent tutorial on installing phpMyAdmin, but there is a slightly easier way to do it by using the EPEL repository. I cover that method in an article at http://joshprewitt.com/2011/03/08/install-phpmyadmin-on-centos-5-5-using-epel-repo/ If you have a problem, question, or comment with either of these methods, post a comment and I’ll try to help you out!

Install Apache

First, install apache as described at: http://cloudservers.rackspacecloud.com/index.php/CentOS_-_Apache_and_PHP_install but stop before you get to installing PHP.

You will need to modify your /etc/httpd/conf/httpd.conf file beyond that to look for index.php as a Directory Index. Look around line 391 for:

DirectoryIndex index.html index.html.var

Change this to include index.php like:

DirectoryIndex index.php index.html index.html.var

Install MySQL

Next up, we need to install MySQL

yum install mysql-server

Now start it up

service mysqld start OR /etc/init.d/mysqld start

Now we need to secure it:

/usr/bin/mysql_secure_installation

It is going to ask you handful of questions:

Current Root Password

You will be asked for your current root password. Because this is a new installation it is set to none. Press enter.

Set Root Password

If the above step worked correctly you should be prompted with a question asking you if you would like to set your root password. Please press Y and press Enter.

You will be asked for your root password twice. If it works you will see Success!

Removing Anonymous Users

You will be prompted to remove the MySQL anonymous users. For security reasons we want to do this. The text above the question explains this topic in more detail. Press Y and then Enter.

Disallow Root Login

You will be asked if you would like to disallow remote login for the root user and only allow connections from the server itself. To keep our server secure you want to say Y and press Enter.

Delete test Database

MySQL ships with a default database called test. This is not needed and can be deleted. Press Y and then Enter to delete the test database and it’s associated users.

Reload Privilege Tables

This step will reload the user settings (called privilege tables) so all user changes will take effect. Press Y and then Enter to continue.

This post won’t go into setting up additional users besides root and assigning them privileges. For information on that, check out the Cloud Servers Knowledge Base: http://cloudservers.rackspacecloud.com/index.php/CentOS_5.4#MySQL

Install PHP

Now, we need to install php. The problem is that the default yum repos have php 5.1, and the current version of PhpMyAdmin requires 5.2 or higher. To install that version of php, we will need to enable the “testing” repo.

To do that, edit the file /etc/yum.repos.d/CentOS-Base.repo to include this at the bottom:

[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

Great – now we can actually install php

yum install php php-common php-gd php-mcrypt php-pear php-pecl-memcache php-mhash php-mysql php-xml php-mbstring

Install PhpMyAdmin

Now finally, we are ready to install PhpMyAdmin! The easiest way to do this is to drop into a new directory called phpmyadmin in the web root of the server. Change directory to the web root:

cd /var/www/html

Now perform a wget to download the latest version. Head over to http://www.phpmyadmin.net/home_page/downloads.php to see what the latest version is. At the time of this writing, the latest version is 3.3.6. Personally I will download the english tar file with gzip compression. Click the link, cancel the download, and then copy the “Direct link” location that is at the top of the screen. In this case: http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.6/phpMyAdmin-3.3.6-english.tar.gz?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php&ts=1283745912&use_mirror=voxel

So the command is:

wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.6/phpMyAdmin-3.3.6-english.tar.gz?r=http%3A%2F%2Fwww.phpmyadmin.net%2Fhome_page%2Fdownloads.php&ts=1283745912&use_mirror=voxel

Next, we need to untar/unzip it.

tar zxvf phpMyAdmin-3.3.6-english.tar.gz

Let’s rename the directory to make it easier to remember:

mv phpMyAdmin-3.3.6-english phpmyadmin

Now, we need to setup the blowfish secret phrase. This is just a random phrase that will be used to encrypt/decrypt data. Let’s make a copy of config.sample.inc.php over to config.inc.php.

cd phpmyadmin
cp config.sample.inc.php config.inc.php

Now, edit this file at line 18 where it says:

$cfg['blowfish_secret'] = '';

Make it read:

$cfg['blowfish_secret'] = 'TypeSomeRandomStuffHere';

Ok, last but not least, let’s give apache one final restart:

service httpd restart

You can now access it by going to either yourdomain.com/phpmyadmin or yourip.com/phpmyadmin

Cleanup

The login will be root and whatever you set the root password to be. Now to cleanup, let’s disable the testing repo, just edit the /etc/yum.repos.d/CentOS-Base.repo file to be enabled=0 instead of enabled=1.

Leave a comment ?

14 Comments.

  1. Thanks for the guide, it help a lot.

  2. Chris Kenward

    Excellent. Nice and clear – thanks so much.

  3. Works great
    Used this procedure on 3 different machines from remote and installs easily

  4. Zoltan Horvath

    Thank you so much, it worked like a charm.

  5. Thnx U very much , it worked for me on my CnetOS 5.5

  6. This is the first time i work with linux centos and your tutorial helps me great. Keep up the good work!
    Sorry for my bad English.

  7. nice article. thank you so much

  8. thnaks a lot its working fine on my centos Server

  9. PhpMyAdmin thx

  10. this very good tutorial. I have first time work on cloud server. it was gr8

  11. thank you! awesome! centos 6.

  12. Great!!!!!!!!!!

    So simple and target

  13. nice guide, thank you it’s help me to setup phpmyadmin on centos. :grin:

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks and Pingbacks: