Cent OS upgrade PHP

I'm in the midst of resolving a bunch of security issues on a clients server to get them compliant with credit card laws and such.

The first order of business is getting php from 5.2.14 to 5.2.16.

When I run yum update php, this is the output I get:

Excluding Packages from CentOS-5 - Addons
Finished
Excluding Packages from CentOS-5 - Base
Finished
Excluding Packages from CentOS-5 - Extras
Finished
Excluding Packages from CentOS-5 - Updates
Finished
Setting up Update Process
No Packages marked for Update

I'm fairly new to CentOS, but with Debian/Ubuntu, you can add PPAs to allow new software packages. Is there something similar for CentOS? This output makes it look like it's ignoring all the main package repos as well.


Solution 1:

I highly suggest using the IUS Community Project repositories for upgrading your PHP 5.2, and even PHP 5.3 packages on CentOS 5. These are a set of very well maintained and high quality packages, used by Rackspace and maintained, but not supported by them (unless you're a customer of course).

The install instructions can be a little hard to find if you're new to this. You're looking for the client usage guide on their wiki. I will duplicate the instructions here for ease of use.

[root@linuxbox ~]# wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/ius-release-1.0-6.ius.el5.noarch.rpm 

[root@linuxbox ~]# wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/epel-release-1-1.ius.el5.noarch.rpm

[root@linuxbox ~]# rpm -Uvh ius-release*.rpm epel-release*.rpm

This downloads and installs both the EPEL and IUS repos for you.

IUS promises not to use conflicting package names with any of the official repos, including EPEL (this is a great thing), things aren't as simple as yum upgrade php. You will need to first uninstall all of your existing PHP packages, and install the appropriate ones from IUS. Alternatively, you can use the yum-plugin-replace plugin to add a useful "replace" capability to YUM.


Manually

First:

[root@linuxbox ~]# rpm -qa | grep php

[root@linuxbox ~]# yum erase php
  • rpm -qa | grep php lists each installed PHP package. You will use this list to install all the appropriate individual PHP packages from IUS
  • yum erase php command just erases PHP and it's dependent packages

Finally:

[root@linuxbox ~]# yum search php52

[root@linuxbox ~]# yum install php52 php52-common php52-pecl-apc php52-mysql ...
  • yum search php52 lists the available PHP 5.2 packages
  • yum install installs your chosen PHP 5.2 packages. You would use the list you obtained in step one to determine which you needed

yum-plugin-replace

[root@linuxbox ~]# yum install yum-plugin-replace

[root@linuxbox ~]# yum replace php --replace-with php52

This will magically determine which PHP packages to erase, and which matching php52 packages to install for you.