How to add APC cache to Magento

Image for How to add APC cache to Magento from

By Andrew McCombe
May 10, 2012

The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. It can help speed up your Magento installations.

First, install the PHP APC package (Assuming you are using Ubuntu as your web server):

sudo apt-get install php-apc<

Now configure APC for use with Magento. Edit /etc/php5/conf.d/apc.ini:
apc.enabled = On
apc.optimization  = 0
apc.shm_segments = 1
apc.shm_size = 512
apc.ttl = 7200
apc.user_ttl  = 720
apc.num_files_hint = 1024
apc.mmap_file_mask = /tmp/apc.XXXXXX
apc.enable_cli = 1
apc.cache_by_default  = 1
apc.max_file_size = 10M
apc.stat = 0
#apc.include_once_override = 1

Once you have changed the apc.ini file you will need to restart the Apache Web Server:

service apache2 restart

Finally, configure Magento to use APC: Edit app/etc/local.xml and add the following:


That's all there is to it. To check that APC is being used you can use the APC.php file as discussed in my post.