Upgrading PHP (from 5.1 to 5.3 for example) on a variety of common RPM based linux distributions (CentOS/RHEL, Whitebox, Fedora, etc) can be a tricky process. After some searching and playing around, I come across a simple method which should meet the needs of most. There is a fantastic repository known as the IUS Community Project.
We are committed to providing up to date and regularly maintained RPM packages for the latest upstream versions of PHP, Python, MySQL and other common software specifically for Redhat Enterprise Linux and clones.
A Word of Warning: Do not attempt the following on a server that has cPanel/WHM installed on it. You will break your server! Use the Easy Apache Updater through the WHM interface or the Easy Apache Updater script:
/scripts/easyapache on the command line, to upgrade your PHP version and features.
The following process should get you were you want to be.
- Download and Install the IUS repositories. You can start here: http://dl.iuscommunity.org/pub/ius/stable/Redhat/. Pick your release version and architecture (execute the command
'uname -a'(as root without the quotes) on the command line if you are unsure which you version you are using).
- Download the two repository packages. The first package will have a file name starting with epel-release (
epel-release-1-1.ius.el5.noarch.rpmat the time of writing) and the second file will have a file name starting with ius-release (
ius-release-1.0-6.ius.el5.noarch.rpmat the time of writing). On the command line, as root, you could execute the following commands:
wget -c http://dl.iuscommunity.org/pub/ius/stable/Redhat/5.5/x86_64/epel-release-1-1.ius.el5.noarch.rpmto download the EPEL IUS repository installer for CentOS (and variants) on the 64bit platform and
wget -c http://dl.iuscommunity.org/pub/ius/stable/Redhat/5.5/x86_64/ius-release-1.0-6.ius.el5.noarch.rpmto download the IUS repository installer for CentOS (and variants) on the 64bit platform.
- Install the repositories, starting with the epel-release repository first:
rpm -ivh epel-release-1-1.ius.el5.noarch.rpmand then
rpm -ivh ius-release-1.0-6.ius.el5.noarch.rpm.
- Clear the system yum cache with this command:
yum clean all
- Make sure the version want and related components are available:
yum list php5*
- Remove any existing php and related components:
yum remove php*
- Install the base php version you are after:
yum install php52.x86_64
- Install any additional components or modules you may require:
yum install php53u-eaccelerator.x86_64 php53u-ioncube-loader.x86_64 php53u-mbstring.x86_64 php53u-mcrypt.x86_64 php53u-mysql.x86_64 php53u-pdo.x86_64 php53u-xml.x86_64 php53u-xmlrpc.x86_64 php53u-gd.x86_64and any others in the list that you want.
It is worth noting at this point, that both the IUS repository and the IUS EPEL repository are still enabled. Care should be taken in leaving them enabled, especially if you have yum automatically updating your software on a regular basis. If this is the case, or you don’t want to risk breaking your system with yum late one night, disable these repositories as follows:
- As root on the command line, navigate to the yum repositories directory:
- Edit epel.repo file and change the
'enabled=0'You could use ‘nano’ (
yum install nanoif you don’t have it):
nano epel.repochange the line and press ctrl+o and then ctrl+x to save and exit
- Edit the ius.repo file and change the
'enabled=0'Again, you could use ‘nano’:
nano ius.repochange the line and press ctrl+o and then ctrl+x to save and exit.
- Finally type:
yum clean all
Leaving the IUS repositories enabled shouldn’t really cause you any problems. Then again, waking up one morning to find MySQL 5.0.x is now 5.1.x and everything on your server is now broken or not working, may be a good enough reason to disable them until needed, avoiding any accidental upgrades.
There isn’t one. But there is the testing repository. Edit your /etc/yum.repos.d/CentOS-Base.repo file or create a new /etc/yum.repos.d/CentOS-Testing.repo file with the following in it:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to function properly.
# These packages build and install, but are waiting for feedback from testers as to
# functionality and stability. Packages in this repository will come and go during the
# development period, so it should not be left enabled or used on production systems without due
Be sure to change the value of the line ‘enabled=0’ to ‘enabled=1’ when you want to use the repository. Change it back to ‘0’ when you are finished, to avoid any accidental upgrades.
Feel free to post your comments and feedback. If you need a little extra help, please do let me know.