Saturday, March 27, 2010

Installing PHP 5.3.x on RedHat ES5, CentOS 5, etc

Some cases arise when we want to upgrade php and we do not want to affect any dependencies it has.

Obviously we can use YUM for this ;)
The step below will upgrade your php with all it dependencies to latest version. We have 5.3.1 at the moment.

To install PHP 5.3.1 (latest version) you can make use of a RPM repository maintained by Remi. We will cover here for ES5 stuff.
So first of all we will need to get the latest remi release
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm 
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
You now have the Remi repository on your system, however it is disabled by default. Obviously you don’t want all of your packages been effected by this repository, however to enable it for a specific package, run the following:yum --enablerepo=remi update php
Now you can just run 
php -v
This will give you the version of php.
You can now restart your server.

Upgrade to PHP 5.2.10 - CentOS5 using YUM


There is a version of PHP (5.2.10) in CentOS’s Testing repository. You could either download each rpm and install, or set up your yum to install from the testing repository.
Install the testing repository’s GPG key:
rpm --import http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
And download the CentOS-Testing repo file:
cd /etc/yum.repos.d
wget http://dev.centos.org/centos/5/CentOS-Testing.repo
Now you can install/update to PHP 5.2.10 by running
yum --disablerepo=* --enablerepo=c5-testing update php

Developer Instincts