I’m : a programmer, writer, podcaster, geek, and coffee enthusiast.

How to get PHP 5.2.4 in yum on CentOS or Fedora Core

(geek level of this post: 90%)

This is so useful that I’m embarrassed that I didn’t know about it earlier. I hate compiling PHP outside of the module-level convenience of yum on a CentOS or Fedora server, but I love coding against some features that only exist in PHP 5.2 and above, such as DOMDocument::register_node_class (for customizing the XML DOM with convenience methods and extra functionality) and DateTimeZone (which exists in 5.1, but only with a custom compilation flag that’s not set in the yum-repo version).

Anyway, go here and set up the remi yum repository with that simple wget/rpm command for your OS. The page is in French, but it doesn’t matter. I figured it out, and the only French I know is that télécharger means “download”.

Example: For CentOS 5, go to the RHEL 5 section and run these commands:

wget http://[big long URL].el5.remi.noarch.rpm
rpm -Uvh remi-release-5*.rpm

Then you have the remi repository on your system. It’s disabled by default (in /etc/yum.repos.d) so you don’t accidentally upgrade unwanted components with automatic yum updates. To enable it for a particular package, like to get the latest PHP, do this:

yum --enablerepo=remi update php

Done. Don’t forget to upgrade any additional modules that you’ve installed outside of yum’s management (for me, I needed php-memcache and php-apc). Other PHP modules that you already have installed, such as php-mbstr, php-mysql, and php-gd, are updated with PHP automatically from remi.

[root@server ~]# php -v
PHP 5.2.4 (cli) (built: Aug 31 2007 16:02:49) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies