Saturday, March 27, 2010

How I updated PHP & MySQL on RedHat Enterprise Linux (RHEL) 5.3

SkyHi @ Saturday, March 27, 2010

This is my post about the steps which I used to update the versions of PHP and MySQL on RHEL 5.3. As of this writing the latest versions of PHP is 5.2.9 and that of MySQL server is 5.1.32-1. The installation of RHEL5 (after making updates) had versions of PHP/MySQL which were as much as 2.5 years old. You obviously don’t want so old versions of the software for security reasons. So I decided to upgrade versions of PHP/MySQL on the system. Obviously the default repository of RHEL does not have the updated versions of PHP and MySQL (and many other softwares I believe).


I searched online for making the upgrades and after a long search, I came across links on the web which helped me perform the upgrades. So, I decided to write a detailed post about my upgrade process so it could be helpful to others.


The packet management tool which I’m using is yum. So its a good idea to know few basic yum commands:


yum list available


yum list installed


yum list updates


yum install [package]


yum remove [package]




I guess all of above commands are self explanatory.

Since the repositories which are used by RHEL are not up to date, so we need to use and setup some other repository. One of the most popular and the one which I used is Remi’s repository which has latest packages for most of the software:


http://rpms.famillecollet.com/index.html


This repository is not there in the repository directory


/etc/yum.repos.d


yet so we need to enable it in order to use it. To do that we need to download some additional RPMs and install them first. The 2 RPMs which we need are:

epel-release and remi-release

My architecture is i386 so if yours is x86_64 then get the RPMs for it accordingly.


We can get the first one from here:

http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm


using:


wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm


rpm -Uvh epel-release-5-3.noarch.rpm


Download the 2nd one from Remi’s site:

http://rpms.famillecollet.com/enterprise/remi-release-5.rpm


using:


wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm


rpm -Uvh remi-release-5.rpm


2nd package is dependent on first one so we need to install 1st before the 2nd.


Now, I removed the older packages first (not sure if this was needed though) by using:


yum list installed


and looking for those packages which started with php or mysql. That also included php packages dependent on mysql and vice-versa. Remove them using:


yum remove [package]


IMPORTANT: I didn’t mention it here but if you have any data present (especially MySQL database) then please make sure that you back them up first before removing packages as that may result in loss of data also. I didn’t have any data when I started so I didn’t mention it before.


The steps will now create corresponding information for Remi’s repository in:


/etc/yum.repos.d/


So, now we have the older packages removed and need to install the new ones. Before that we need to enable Remi’s repository. For that goto file called remi.repo in the repo directory and under the section [remi] there, change enabled = 0 to enabled = 1.


After doing this, run the following command:


yum install php


Now, run:


php -v


and you should get something like this:


PHP 5.2.9 (cli) (built: Feb 27 2009 14:42:58)

Copyright (c) 1997-2009 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies


as the output.


Now, run the following commands:


yum install mysql-server

yum install php-mysql


yum install mysql-devel


and it should install MySQL server and PHP-MySQL module along with necessary dependencies.

Now, you can check your working of PHP and MySQL server by starting httpd and mysql services and may be writing a phpinfo() file:


/sbin/service httpd start

/sbin/service mysqld start


So the PHP and MySQL should be working now. I have not yet done any configuration of any of those and its likely that I’ll run into some problems there and so may be I’ll make another post about it.

Some of the links which were useful to me and from where I used information for the installation process:


https://forums.misdivision.com/showthread.php?t=1285

http://timt881.wordpress.com/2009/02/17/installing-phpmyadmin-and-php-52-on-a-centos-52-server/

http://forum.parallels.com/showthread.php?t=86086


Since this thing worked for me for RHEL 5.3 so I believe it should work for CentOS as well.


REFERENCE

http://binit933x.wordpress.com/2009/03/05/how-i-updated-php-mysql-on-redhat-enterprise-linux-rhel-53/