views:

68

answers:

3

when we deploy our app, we simply create a new folder and point a symbolic link to it, so apache will always find its way to the latest build.

However, we get strange errors when we deploy and continue testing without first rebooting the apache server. We also have APC running and have a feeling that caching has something to do with this.

Is it normal that an apache restart is required when deploying a new version of our php application when APC is active? Or is there a better way, e.g. clearing the APC cache using a shell script?

+4  A: 

depends if you have the apc.stat setting in php.ini On or Off. If Off (typical for a production site) then you need to clear the code cache or restart apache; if On, then it should pick up the new code automatically

Mark Baker
Then the question becomes, why is off the default setting for production? What's the downside of having it on?
Vinko Vrsalovic
The stat check defaults to On, which is what you need in a development environment where you're constantly changing code and don't want to have to clear the cache or restart the server whenever you make a change. But in a production environment, code should be static (except for controlled/scheduled changes) and the stat check should be set Off because it reduces the slight overhead of checking whether a script file has been changed or not whenever it is accessed.
Mark Baker
@Mark: I'd add that reasoning to the answer.
Vinko Vrsalovic
A: 

Normally, APC will 'stat' each PHP file to see if it has been changed since it was last cached. So restarting Apache is not required for all application upgrades.

BUT if your application uses apc_store() to store application data in the cache and some of that data might change after an upgrade, then restarting Apache is an easy way to flush the entire APC cache.

I believe apache2ctl graceful would work, too.

Also, APC performs a little better if you turn off the 'stat' checking; so if you disable that feature, then you'll want to restart Apache anyway.

mehaase