How to enable apc extension under command line php interface (Debian and Ubuntu)

APC is a cache speeding up php execution and allows you to speed up applications by in-memory caching.

Installation of APC on debian / ubuntu

We install the extension using pecl packaging tool (it will download and compile the module).

pecl install apc

If you are asked if you need apxs say no.

Make sure module is enabled in php.ini for command line interface. On debian like systems check if installer did not add anything to /etc/php5/cli/conf.d or /etc/php5/cli/php.ini

If there is no mention of apc.so edit

/etc/php5/cli/php.ini

Enabling APC for the command line interpreter

We have to add just two lines to the appropriate ini file:

apc.enabled = 1
apc.enable_cli = 1 

Now you can check if command line php really loads it by executing

php -i | grep 'apc'

If it shows anything then you are done, otherwise you have to make sure you are editing the correct ini file so try to look for ini path in

php -i

Comments

It's worth noting that the

It's worth noting that the PHP page on APC points out the cache is created on each CGI request (http://us.php.net/manual/en/apc.configuration.php#ini.apc.enable-cli).

2011-05-15 12:58
Steve

Post new comment

Image CAPTCHA

About the author

Artur Ejsmont

Hi, my name is Artur Ejsmont,
welcome to my blog.

I am a passionate software engineer living in Sydney and working for Yahoo! Drop me a line or leave a comment.

Enjoy!