Installing APC on PHP 5.3

In a previous post I had some instructions for building PHP 5.3 on 64-bit CentOS 5. Turns out the caching extension listed there, eAccelerator, didn’t show a marked performance benefit in our benchmark testing. So instead I decided to play with APC, one of the competitors. Getting this installed was a bit tricky though (e.g., compiling statically errors out), so follow these steps:

# First build PHP as usual, since we'll be installing this as a shared extension
# Then try to get rid of any leftover header files
yum remove php-devel
 
# Symlink your "real" php include directory
mv  /usr/local/include/php /usr/local/include/php-previous-version
cd /usr/local/include
ln –s /path/to/new/php/source/dir php
 
# only the beta version of APC works on PHP 5.3; see http://pecl.php.net/bugs/bug.php?id=16078
pecl install apc-beta
mv /usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so /usr/lib/php/modules
 
# copy the APC dashboard script to your webroot
cp /usr/local/lib/php/apc.php /path/to/your/webroot
 
# Add the extension in a new file /etc/php.d/apc.ini
; Enable apc extension module
extension=apc.so
apc.enable = 1

Bounce apache and then go to yourdomain.com/apc.php to see the status.

Enjoy.

1 comment

Leave a comment

Your email address will not be published. Required fields are marked *