You are reading

Installing APC for PHP 5.3

Posted: September 2, 2009 | By: TJ | In Technology | No comments yet

After attempting to install APC, an opcode cacher on my Lenny server, I found that the version included in the Lenny package isn’t compatible with PHP 5.3. APC has released a version that is compatible so you’ll need install the PHP extension from source. The pecl error with version 3.0.19 was:

/tmp/pear/temp/APC/php_apc.c:959: error: duplicate 'static'
make: *** [php_apc.lo] Error 1
ERROR: 'make' failed

Luckily, installing from source is pretty easy:

$ cd /usr/local/src
$ wget http://pecl.php.net/get/APC-3.1.3p1.tgz
$ tar xzvf APC-3.1.3p1.tgz
$ cd APC-3.1.3p1
$ phpize
$ ./configure --enable-apc --enable-mmap
$ make
$ make install

After the extension successfully compiles, you’ll need to move the apc.so into your extension directory — this may differ depending on your system:

$ cp /usr/local/src/APC-3.1.3p1/modules/apc.so /usr/local/lib/php/extensions/no-debug-non-zts-20090626/

Copy the following into the php.ini:

extension = apc.so
apc.enabled=1
apc.shm_size=30

Restart the web server and if applicable, the php daemon:

$ /etc/init.d/nginx restart && php-fpm restart

To verify that everything has been set up properly, load a phpinfo page in the document root. You should have the APC PHP module displayed:

APC Module

Click to enlarge

Leave your comment



Copyright © 2010. All rights reserved.

This blog is powered by WordPress and proudly hosted by (mt) Media Temple.