You are reading

Installing APC for PHP 5.3

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

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

Comments for this entry

[...] stable patch method works well however it still requires you to compile PHP manually. This is considered the [...]

Have you a complete tutorial between Nginx 0.8.36 + php-fpm 5.3.2 + wordpress on Ubuntu 9.04. I need that, please.

Thank you before.

Thanks a lot for this very useful article. Everything works like a charm =)

Jim

Just want to say thank you for sharing your knowledge in this matter. Following the steps that you have outlined in this article I’ve been able to put a close to one frustration. Now smooth sailing until the next bug/errata surfaces. Thank you.

Just for the record, the problem seems to be fixed in apc-beta.

You can ‘sudo pecl install apc-beta’, and it installs fine, at least on Lucid.

Super-helpful. Thanks!

Michael

Confirmed. `pecl install apc-beta` also works here (Fedora Core 13). As of 2010.08.14, the beta APC that I grabbed and installed is 3.1.4.

marcofang

This is short and easy, also proved super useful! Thanks the great snippet.

BTW, the “copy to clipboard” js function includes the leading “$” symbol in the clipboard.

Leave your comment



Copyright © 2010. All rights reserved.

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