Archive for April 28th, 2007

How to install APC and php4-memcache extension on Debian Sarge

Saturday, April 28th, 2007

To improve the PHP performance, I started playing with APC (Alternative PHP Cache) and memcached recently. However, to install the APC extension and PHP-Memcache client on Debian Sarge turned out to be not that trivial. Here I’d like to share my experience. It serves as my own personal record as well.
First of all, you need to have PHP4-dev and Pear package installed on your system:

apt-get install php4-pear php4-dev

In order to use the ‘pecl’ installation tool, you need to upgrade the bundled PEAR version to the latest:

pear upgrade pear-1.3.3
pear upgrade Archive_Tar
pear upgrade Structures_Graph
pear upgrade pear
pear upgrade-all

After the upgrade, you need one more step before proceeding with the pecl installation. If you don’t do the following you will have the error like this when compiling php-memcache: (configure: error: Cannot find php_session.h). Thanks to this post, I found the solution: you need to create the following symoblic link:

ln -s /usr/include/php4 /usr/include/php

Okay, final step is easy:

pecl install apc memcache

For APC, you may just choose not to compile with aspx-support, if it prompted you to select.

Now sit back, and wait for the compilation to finish. After it is done, you just need to enable the modules in your PHP.ini configuration file, which I am not going to touch upon here.

Good luck with your optimization for PHP code.