I recently installed APC (Alternative PHP Cache) on one of our servers and I want to provide a step by step guide so that others can benefit from my experience. We had both php4 and php5 installed in the server and I wanted to install the accelerator for php4 specifically. When I used pecl to install the extension, it ended up in the php5 modules directory.

$ sudo pecl install apc
downloading APC-3.0.19.tgz ...
Starting to download APC-3.0.19.tgz (115,735 bytes)
.....................done: 115,735 bytes
47 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
[some more output]
install ok: channel://pecl.php.net/APC-3.0.19
You should add "extension=apc.so" to php.ini

Since I wanted to have install APC for php4, I went down the manual way:
Step1: Download and unzip APC

$ wget http://pecl.php.net/get/APC-3.0.19.tgz
$ tar xvzf APC-3.0.19.tgz
$ cd APC-3.0.19/

Step2: Use phpize to prepare the source code. If you do not have phpize, you can get it from php4-dev (or php5-dev if you are using php5) package on Debian.

$ phpize

Step3: Use ./configure to create library settings etc. Make sure correct php-config is on your path. Then do make. You will have the apc.so module file in the modules directory in the current path. You can copy that to your php modules directory or ask make install to do it.

$ ./configure
$ make
$ make install

Step4: Ensure that the module is copied to the correct place. As a final step, you need to edit your php.ini file so that the module is loaded:


That's all, enjoy your new bytecode optimizations. I'll write another post detailing what speedup I was able to observe.