I'm setting up a webserver to host several small sites (mostly wordpress) by putting together php-fpm 5.5.9 and apache 2.4.10 on ubuntu.
After reading a good amount of tutorials and post, I decided to setup php-fpm to run a socket per website and to use mod_proxy_fcgi on apache to redirect the requests to the php-fpm.
<LocationMatch "^(.*\.php)$">
ProxyPass unix:///var/run/php5-fpm-saintsein.com.sock|fcgi://127.0.0.1:9000/home/saintsein/public_html/
</LocationMatch>
I got everything running almost smoothly but once i enable Zend Opcache in the php configuration. I'm randomly getting error messages on the website.
The only log entry I'm getting is this:
Connection reset by peer: [client 194.78.30.55:55202] AH01075: Error dispatching request to :
I have been looking around the web and I couldn't find anyone with this specific error to Zend Opcache status.
Does anyone have any idea of what could be wrong ? Or how I can debug it?
Best Answer
When I've seen similar issues in our environments, it appears to have been because of the way that OpCache (by default) shares a single cache across all users on a shared hosting environment. A bug has been submitted (and you can, and should, go and vote to let the maintainers know how important this might be for your use case) though no commitment has been made on delivering a fix.
TL;DR : By default when OpCache is enabled, the cache that is used to store compiled byte-code is shared across all users. In an environment where hosting is shared between multiple sites / users, this can result in a site grabbing the cached output of php scripts from another site or, if specific security settings are enabled even generating errors.
Although no fix has been officially released, if you're using cPanel, this wiki has a documented way of configuring the php-fpm pools to be created and secured on a per-user basis and if you follow the instructions below as well as the IMPORTANT NOTES at the bottom of this answer you should be able to get the functionality you desire without any errors
That post also documents how you might configure this by hand on a per-site/per-user basis (though I'd wager that might become tedious if you're hosting a lot of sites). If you're not using cPanel, you may need to modify the scripts to specify your individual paths and usernames instead of the variables being used by cPanel's config engine.
IMPORTANT NOTES
During testing and additional research I came across this article which provide a few clarifications that may be relevant to your specific situation:
opcache.use_cwd
parameter is set totrue
for your application's configuration of OpCache - it's set tofalse
by default and leaving it set to default will probably cause collisions if you're hosting more than one PHP application on your system:opcache.load_comments
andopcache.save_comments
directives are set totrue
. You should double-check this suggestion with your application / framework documentation as most have now updated their docs with specific instructions on enabling the use of OpCache properly for their systems:IMPORTANT NOTES
Hopefully this helped - and if you're using cPanel, drop a comment to let us know how you tackled that portion of the configuration! See also this question and associated comments.