I'm using Nginx 1.8.1 as a reverse proxy in front of PHP 5.6.20 over FastCGI (PHP-FPM), and I'm finding that all the notice/warning/error logs from PHP are also being logged in Nginx as errors. Is there any way to prevent such logs from propagating to Nginx' logs? I want them logged in PHP's log file only.
Here's an example:
[29-Apr-2016 22:23:10] WARNING: [pool www] child 20 said into stderr: "NOTICE: PHP message: PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /opt/web-app/index.php on line 2"
That same log is them added to Nginx' log file as an error:
2016/04/29 22:23:10 [error] 6#0: 1 FastCGI sent in stderr: "PHP message: PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /opt/web-app/index.php on line 2" while reading response header from upstream, client: 172.18.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://172.18.0.2:9000", host: "localhost:8080", referrer: "http://localhost:8080/index.php"
Is there any change that I can make to my very simple configuration files for Nginx or PHP-FPM?
I've been looking at the same issue, and after some trial and error, what worked for me is adding the below into the php-fpm pool configuration. I assume that the same flag could be set in other ways, such as the main php.ini
file.
php_admin_flag[fastcgi.logging] = off
The relevant documentation is here: https://www.php.net/manual/en/ini.core.php#ini.fastcgi.logging
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With