how to install apc cache for magento

how to install apc cache for magento

July 19, 2026 · Illustrated author avatarBy Stefan Bogdanescu
how to install apc cache for magento

Setting Up APC Cache for Your Magento Website

Welcome! As an experienced developer, I understand that optimizing your Magento website’s performance is crucial. One effective way to do this is by setting up the Alternative PHP Cache (APC) system. In this comprehensive guide, I’ll walk you through the entire process from start to finish.

Step 1: Verify APC Installation

First, let’s confirm if APC is already installed on your server. Your hosting provider has informed you that it is installed, but we should verify it using PHP_info().

<?php
phpinfo();
?>

Look for the “apc” section in the output. If you see it, great! We can proceed to the next step.

Step 2: Configure APC

Next, we need to configure APC for use with Magento. You’ll find that your current configuration does not include the necessary settings for Magento.

Create a new PHP file (e.g., apc.ini) and add the following lines:

; APC Configuration
extension=apc.so
apc.enabled=1
apc.shm_segments=4
apc.optimization_level=0
apc.stat=1
apc.cache_by_default=1
apc.canonicalize=0
apc.stat_ctime=0
apc.shm_max_memory=256MB

Replace the memory value (apc.shm_max_memory) with a suitable amount for your server.

Step 3: Enable APC in Magento

Now, let’s enable APC within your Magento application. Open the app/etc/local.xml file and add the following inside the <config> tags:

<global>
    <cache>
        <backend>apc</backend>
        <frontend>
            <name>Default_Cache_Frontend_Transient</name>
            <id_prefix>mage-</id_prefix>
            <life_time>3600</life_time>
        </frontend>
    </cache>
</global>

This tells Magento to use APC as the cache backend.

Step 4: Flush Your Cache

Finally, let’s flush our existing cache. This ensures that any old data is cleared and the new configuration takes effect:

php bin/magento cache:flush

Step 5: Verify Configuration

To confirm everything works correctly, you can use Magento’s built-in cache management in the backend (System > Cache Management). Make sure all your caches are enabled.

Conclusion

That’s it! You’ve successfully configured APC for your Magento website. This setup will significantly improve your site’s performance by caching PHP bytecode and reducing database hits.

Remember to monitor your server’s resource usage and adjust the APC configuration as needed, especially around peak traffic times. If you need further assistance or want more advanced tuning options, feel free to explore our in-depth guides on cache optimization techniques.

Happy optimizing!

Cache Database Performance Extensions

Our network