PHP with APC: Fatal errors: Cannot redeclare class

Poru picture Poru · Jan 1, 2011 · Viewed 22.3k times · Source

Since I installed APC for PHP with PECL I get sometimes these errors: Cannot redeclare class xxx

xxx changes from time to time. I could disable APC but APC improves the performance great! Is there a known bug or could I do something else to prevent these errors? I'm using Ubuntu 8.04 LTS with PHP 5.2.4.


Edit/Update (from comments):

I use the Zend Framework Autoloader and these error never occurred before I enabled APC. A few moments ago I get for example that error: Fatal error: require(): Cannot redeclare class zend_db_adapter_abstract in /paths/app/lib/Zend/Db/Select.php on line 27

Answer

Peter picture Peter · Feb 12, 2012

The combination of the following configs fixed it for me:

apc.include_once_override = 0
apc.canonicalize = 0
apc.stat = 0

Without all 3, I'd constantly get the error, but with all three I seem to no longer get the error :)!