Upgrading to PHP 5.3 on CentOS 5.x Linux

Some of the earlier CentOS/RHEL version 5.x Linux distributions came with older PHP versions (like 5.1 etc) and many newer PHP based open-source software distributions (eg: latest WordPress) require the better and newer versions of PHP like 5.3 or higher, so here’s some quick commands to run as root on a CentOS 5.x operating system to upgrade its PHP version to 5.3.x
Do note that this does require installing the Fedora “EPEL” Repository to gain access to the newer PHP Packages.

First, shutdown any running software that’s using PHP, mostly this is the Web Server:

service httpd stop

Then due to nasty RPM dependencies (particularly if you have the frequently used ‘phpMyAdmin’ software installed), we recommend that you remove all currently installed PHP software packages, which can be identified and then removed with the following commands:

yum list installed | egrep ^php
yum remove php php-cli php-common php-gd php-ldap php-mbstring php-mcrypt php-mysql php-pdo

Then install the equivalent new PHP packages from the EPEL Repository, installing that Repo file first, with the following commands:

cd /usr/local/src
wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -i epel-release-5-4.noarch.rpm
yum install php53 php53-cli php53-common php53-gd php53-ldap php53-mbstring php53-mcrypt php53-mysql php53-pdo

All done, so now restart the Web Server (Apache in this example) with:

service httpd start

And check the Apache web server logs to see that it’s running Ok with the new PHP, eg: tail /var/log/httpd/error.log

FYI,
Richard.

This entry was posted in Network Presence and tagged , , , . Bookmark the permalink.