How to install PHP APC through PEAR

If you try to install PHP APC 3.1.5 through PHP PEAR and encounter errors regarding phpize or the following:

/usr/include/php5/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory

…well don’t worry. You’re missing a few components. For phpize, you’ll need the php5-dev that you can fetch from Ubuntu. For the php_prce.h error, you’ll need pcre3-dev package which is essentially Perl 5 Compatible Regular Expression Library – development files.

Perform the following and install PHP APC using PECL again:

sudo apt-get install libpcre3-dev php5-dev
sudo pecl install apc-3.1.5

And it’s done:

Build process completed successfully
Installing '/usr/lib/php5/20090626+lfs/apc.so'
install ok: channel://pecl.php.net/APC-3.1.5
configuration option "php_ini" is not set to php.ini location
You should add "extension=apc.so" to php.ini

This is tested against Ubuntu 10.04 as well as Ubuntu 10.10 environments.

You can add it to /etc/php5/conf.d/apc.ini by:

nano /etc/php5/conf.d/apc.ini

Add in the following codes:

extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.shm_size=32M
apc.cache_by_default=1
apc.stat=1
apc.rfc1867=1 //For Drupal upload progress.
apc.stat=7200 //2 hours

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>