I'm trying to use APC (Alternative PHP Cache) on my localhost with wamp 2, PHP 5.3 and CodeIgniter 1.7.2, however If I turn on cache_by_default and enable apc.stat the server will crash and I get the following error:
[apc-error] Cannot redeclare class ci_benchmark in C:\wamp\开发者_JAVA百科www\k\mvc\codeigniter\Common.php on line 127.
What can I do to fix this issue?
Did you check with this user to see if he ever found a better solution than not enabling cache_by_default?
Does this only happen when you enable apc.cache_by_default AND apc.stat? For performance reasons, you don't want to run apc.stat on a production server. And there is no need to run caching on a dev server at all, other than as a final check before moving to production, at which time you can manually clear the cache.
Is your production server a windows box too? I'm simply asking because it's easy to lose a lot of time tracking down bugs and configuration issues that result from developing and running on different environments. If the production environment is substantially different from your dev environment, this is another argument in favor of turning off caching on your dev box and moving on to the more productive use of your time - developing your app.
When you disable apc.stat, apc seems to have a problem with relative paths. CodeIgniter uses a relative path in the main index.php file, so it breaks things.
Open up index.php and change this:
$system = '../system';
to this:
$system = '/var/www/system';
Substitute '/var/www/' with whatever your server's full path to CodeIgniter's system folder is.
Try changing the requires in that function to include_once. So the file will be only included once. In this function I mean: system/codeigniter/Common.php: function &load_class($class, $instantiate = TRUE), I guess that should help. I think APC is caching to aggresively.
精彩评论