After installing the latest Mac OS X Leopard security update, namely Security Update 2008-002, my Apache stopped working. Apache's error log showed the reason why:

PHP Warning: [eAccelerator] This build of "eAccelerator" was compiled for PHP version 5.2.4. Rebuild it for your PHP version (5.2.5) or download precompiled binaries.\n in Unknown on line 0
PHP Fatal error: Unable to start eAccelerator module in Unknown on line 0

Alright, the eAccelerator extension I use to speed up PHP needs to be recompiled, because the security update has upgraded PHP (from 5.2.4 to 5.2.5). Should be easy, I thought.

A few commands later I had recompiled eAccelerator and restarted Apache by toggling the Web Server option in the Sharing preference pane, and... I got the same error. So, not so easy.

Apparently Apple forgot (shame on you, Apple) to include a few updated files in the security update, required to build PHP extensions. After some trial and error I got eAcceleration compiled and working by making a few changes to the following files (use your favorite text editor, and you will need your admin password):

/usr/bin/php-config
Change
version="5.2.4" to version="5.2.5" and
vernum="50204" to vernum="50205"
/usr/include/php/main/php_version.h
Change
#define PHP_RELEASE_VERSION 4 to #define PHP_RELEASE_VERSION 5
#define PHP_VERSION "5.2.4" to #define PHP_VERSION "5.2.5" and
#define PHP_VERSION_ID 50204 to #define PHP_VERSION_ID 50205

After recompiling eAccelerator (you might need to run make clean before make to clean out the source directory) and restarting Apache you will have a secure PHP without sacrificing your favorite extension!

Note: other extensions may need to be recompiled too but they otherwise usually work fine without the above 'hacks'.

Update: the latest Security Update 2008-005 will update your PHP to 5.2.6, and the same instructions apply. This time, you only have to change the php_version.h, though. And of course, this time change the 4's into 6's instead of 5's.

Disclaimer: use at your own risk, I cannot be held responsible for any problems resulting from the instructions in this blog post.