Over the years I’ve needed to install PhpMyAdmin on a number of servers. This article will cover how to install PhpMyAdmin on CentOS using Yum.
Installing PhpMyAdmin 2.x (I’ll post one for PhpMyAdmin 3.x soon)
For starters, you’ll need to make sure that you have at least PHP 4 or newer installed. Here’s how you can check that.
- Create a new empty php file. test.php for example
- In the file, write: <?php phpinfo(); ?>
- Save the file and upload it to your server
- Goto yourdomain.com/test.php and you will see a page popup with the specifics of your version of php
If you’d rather do this through shell, you can do the following:
cat > index.php
<? phpinfo(); ?>
See below on how to install PHP if it’s not already installed.
If your PHP is older than 4, your REALLY need to have that upgraded. Assuming that you do have php4+, make sure that you also have at least MySQL 3 or newer. These days, most hosting providers use MySQL 5 though some still use 4. I’d say there’s very little chance you’re on anything lower than version 4 so it’s probably not necessary to check.
If you don’t have MySQL installed on your server, you can do the following.
Note: I’m going to assume that you have ssh or shell access to your CentOS server with enough permissions to proceed. A lot of the following is from the command line. All of the italicized text should be typed into shell.
Starting the PhpMyAdmin Install on CentOS
Now that you know you have the back-end requirements, it’s time to get started.
- Start off by updating your packages. It’s generally a good idea to have them up to date anyways
yum install mysql-server mysql mysql-devel
This should take care of installing mysql on CentOS for you. When you first install mysql on CentOS (or any Linux distribution for that matter), there is no password. It is very important that you set this, otherwise you’re leaving open a rather large security hole. You can set up the password from shell by doing the following
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD(‘your-password-here’) WHERE user=’root’;
mysql> FLUSH PRIVILEGES;
Your mysql root password should now be set. You’ll probably also want to add MySQL to the autostart so it starts up automatically after any time you restart your server.
Select Service -> mysql
Next up we’ll install PHP.
Installing PHP on CentOS
We’ll want to install both php itself and some other common related packages. From shell, perform the following commands
yum install php php-gd php-imap php-mysql php-pear php-xml phpxmlrpc curl libxml2 php-mbstring php-mcrypt
Note: The above is one long command. My blog page may have wrapped it so just be sure to type that as one line.
The CentOS server is now all set up and ready to begin the PhpMyAdmin installation
Installing PhpMyAdmin on CentOS
Now that we know our CentOS server is ready to install phpMyAdmin we can download the phpmyadmin packages and get ready to go!
You will need to download phpmyadmin. As of this posting, the most recent version of 2 is 2.11.10, which can be downloaded from http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/2.11.10/phpMyAdmin-2.11.10-all-languages.tar.bz2
tar xvfz phpMyAdmin-2.11.10-all-languages.tar.bz2
mv phpMyAdmin-2.11.10-all-languages.tar.bz2 phpmyadmin
cp config.sample.inc.php config.inc.php
From here you will be editing the configuration file for phpmyadmin. I usually use the nano text editor, but you can use any text editor you wish – such as vi
You will need to edit the blowfish secret line(s) to something unique. This is for your security so do it!
Set an alias for /phpMyAdmin /usr/share/phpmyadmin
Exit your text editor and then…
service httpd restart
PhpMyAdmin is now installed on your CentOS server. Of course you will still need to move a copy onto your website space and change the permissions. Example
cp -R /usr/share/phpmyadmin /home/website/public_html/
chown -R user:group phpmyadmin
Make sure the ‘user’ and ‘group’ are what they need to be! Under no circumstances should you leave the permissions as root!!!
You should now be able to get to phpmyadmin in your browser to begin configuring it at http://your-website-address/phpmyadmin
Question, comments or corrections? Please post them!