APC is an opcode cache that allows PHP to save and reuse the intermediate code generated from PHP source code as a speed optimization.

This tutorial is only relevant for PHP 5.4. PHP 5.5, PHP 5.6, and PHP 7.0 have opcode caching built into PHP, and it is enabled by default.

To enable APC's separate object caching functionality in PHP 5.5+, do not install APC. Instead, install the APCu extension.

To install this extension, SSH into your server as root and run the following command:

sudo apt-get install gcc make autoconf libc-dev pkg-config
sudo pecl5.4-sp install apc

Press Enter when asked configuration questions unless you know you want to change any of the defaults.

Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:

sudo bash -c "echo extension=apc.so > /etc/php5.4-sp/conf.d/apc.ini"
sudo service php5.4-fpm-sp restart

Debugging Compilation Errors

The following error means you tried to build APC for PHP 5.5 or PHP 5.6. PHP 5.5 and 5.6 include opcode caching by default. APC does not work with PHP 5.5+.

/tmp/pear/temp/APC/apc_compile.c:2417:9: error: ‘zend_trait_precedence’ has
no member named ‘function’
make: *** [apc_compile.lo] Error 1
ERROR: `make' failed
Alert: For Control Panel Help & Tutorials, click here: Panel Tutorials
Was this answer helpful? 71 Users Found This Useful (275 Votes)