I noticed the following behavior or PHP-FPM:
Take a look at these two Nginx configs:
server {
listen 80;
server_name example.com;
location / {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /srv/www/i.php;
fastcgi_param PHP_VALUE "display_errors=1";
include fastcgi_params;
}
}
server {
listen 80;
server_name example.net;
location / {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /srv/www/i.php;
include fastcgi_params;
}
}
and /srv/www/i.php
file:
<?php phpinfo();
As you can see the only difference is fastcgi_param PHP_VALUE "display_errors=1";
.
Now if you kill all FPM workers, and open example.net
first, you will see display_errors
is Off
as expected. And at example.com
you will see display_errors
is On
.
But if you visit example.net
again and this request is proceeded by the same worker, you will get display_errors
as On
.
All FPM workers are working in the same pool.
Question: how to make example.net
always work with default settings?
Possible solutions:
- Define
PHP_VALUE
with the desired settings inexample.net
config as well. - Seems to be a "right" solution - create separate pools of workers for each site.
But we have a lot of websites on our server, and both solutions mean a lot of routine work to set up. I was wondering if there is an easier way.
Update:
display_errors
setting in my example was chosen just to demonstrate the problem. The same situation takes place with any php.ini
setting. As per comments, it is a bad idea to mix production and development sites on a single server.