Drupal 6.x And CentOS 5.x

Photo of Greg Harvey
Wed, 2009-09-09 12:07By greg

This is more a bookmark for my reference than anything, but if you have a stock CentOS 5.x installation (maybe from a VPS image or a clean install on a dedicated box) you're going to have issues with Drupal 6.x.

It comes down to PHP version. It ships with PHP 5.1.6 and Drupal these days pretty much depends on PHP 5.2.x upwards to work. Utilities like Drush do too, so leaving PHP as it is, you'll find, is not really an option. To confirm you will have this problem, execute this command to check your PHP version:

$ php -v

I came across this post about installing PHP 5.2.x on CentOS:
http://www.freshblurbs.com/install-php-5-2-centos-5-2-using-yum

The author seems to be a Drupal developer too, as they list a number of modules that will not function with stock CentOS. They also link out to two pages (the only ones you need really). Though I'm re-writing their tutorial slightly, as there are things which will make it easier.

Before you start though, I recommend you update CentOS to the latest packages by running this command:

$ yum update

That will probably take a while, as the chances are your image is a year or so old and updates have never run. It should go smoothly though, as one of the advantages of CentOS (effectively RHEL) is it's tested to destruction before updates are released. =)

Once you've done that, you should install the yum priorities plug-in by following the instructions here:
http://wiki.centos.org/PackageManagement/Yum/Priorities

This software will enforce priorities in the order you state, e.g. if there are two PHP packages in separate repositories that are the same, yum priorities will make sure the highest priority repository takes precedence. (This will make sense once you've read the link above.) I set up the CentOS repositories as advised on the wiki page.

Then you can go here and install Jason Litka's alternative RHEL packages:
http://www.jasonlitka.com/yum-repository/

The instructions here should, in theory, smoothly update CentOS to use Jason's packages (where provided) instead of the main packages. Follow his instructions down to the editing of utterramblings.repo and then use these settings instead:

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
priority=1

Almost the same, but we've added a priority line (equal to the main CentOS base repositories) so the repository is not ignored by yum.

Then *do not* just run yum update as he states. I got a boatload of dependency issues relating to MySQL and Subversion when I did that. All I want to do is update PHP, so instead run this:

$ yum update php*

That will update all the packages whose name begins with "php", all of which make for the PHP update you require, and all were without dependency problems from a stock image (at time of writing). After the update, check PHP version again:

$ php -v

It should say:

PHP 5.2.6 (cli) (built: May 5 2008 14:41:03)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

Sorted! =)

One word of warning... You *might* see something like this:

$ php -v
PHP Warning: PHP Startup: fileinfo: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: readline: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP 5.2.6 (cli) (built: May 5 2008 14:41:03)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

If you do, it's caused by PECL PHP modules that were not updated because they are not in Jason's repository. You need to remove them. You can find out what to remove by running a command like this (taking the "fileinfo" above as an example):

$ yum search fileinfo
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* extras: mirror.sov.uk.goscomb.net
* updates: mirror.sov.uk.goscomb.net
* base: mirror.sov.uk.goscomb.net
* addons: mirror.sov.uk.goscomb.net
===================================================================== Matched: fileinfo ======================================================================
php-pecl-Fileinfo.x86_64 : Fileinfo is a PHP extension that wraps the libmagic library

Now you have the offending module's package name:

$ yum remove php-pecl-Fileinfo.x86_64

If you *need* any of these removed packages, you'll have to find newer RPMs compiled for Jason's recommended PHP version (currently 5.2.6) and re-install yourself. The great thing is these are always only single packages without dependencies, so there should be no need for "dependency hell" to be unleashed.