PHP Fatal Error: Uncaught exception ‘Zend_Cache_Exception’ with message ‘The apc extension must be loaded for using this backend’ in {_PATH_}

 

Solving an APC extension error when using Zend Framework. Goes through the process of installing APC and properly including it in your PHP configuration in Ubuntu.

 

This error is another simple one: you don’t have APC (Alternative PHP Cache) installed. Running a Zend Framework project that requires APC will show this error if it isn’t enabled.

The easiest way to check if APC is enabled is to look at your PHP modules list:

1
$ php -m
$ php -m

If you don’t see APC there, it’s easy to install. You’ll need to grab the package from PECL and then enable it in your php.ini. First we will make sure we have all the dependencies necessary:

1
2
3
4
 $┬ásudo apt-get install php-pear php5-dev apache2-dev libpcre3-dev
 $ sudo pecl install apc --alldeps
 configuration option "php_ini" is not set to php.ini location
 You should add "extension=apc.so" to php.ini
 $ sudo apt-get install php-pear php5-dev apache2-dev libpcre3-dev
 $ sudo pecl install apc --alldeps
 configuration option "php_ini" is not set to php.ini location
 You should add "extension=apc.so" to php.ini

As the message states, we need to add the extension to our PHP config file! This is easy as well:

1
$ locate php.ini
$ locate php.ini

Once you find your config file add this to the end of the file:

1
2
[apc]
extension=apc.so
[apc]
extension=apc.so

Using PHP On The Command Line

If you are using PHP on the command line, you will still get this error. Since you aren’t using the Apache2 configuration, you have to edit another PHP configuration file. Here is my path:

1
/etc/php5/cli/php.ini
/etc/php5/cli/php.ini

Now do the same procedure as above.

Now restart Apache2 and you are good to go.

 
 
 
 
Footnote

This website will always be ad-free. All I ask in return is that you please share this article if you found it helpful.

I also greatly enjoy comments, and will respond to every question in the comments section within a day or two. Don't hesitate to ask for help!

 
 
 
 
Comments

Leave a Reply