2016-04-30 10 views
0

Ich benutze Nginx 1.8.1 als Reverse Proxy vor PHP 5.6.20 über FastCGI (PHP-FPM), und ich stelle fest, dass alle notice/warning/error logs von PHP angemeldet sind Nginx als Fehler. Gibt es eine Möglichkeit, zu verhindern, dass sich solche Protokolle in Nginx-Protokollen verbreiten? Ich möchte, dass sie nur in der Protokolldatei von PHP eingeloggt sind.Wie verhindert man, dass Nginx Fehler von FastCGI/PHP-FPM erfasst?

Hier ist ein Beispiel:

[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"

Das gleiche Protokoll, sie zu Nginx‘Protokolldatei als Fehler hinzugefügt wird:

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 "

Gibt es eine Veränderung, die ich auf meine sehr einfache Konfiguration vornehmen können Dateien für Nginx oder PHP-FPM?

Antwort

0

die catch_workers_output zu no Ändern der Trick tun sollten:

catch_workers_output = no 

So können PHP-Log-Meldungen wie konfiguriert, aber diese Nachrichten verhindern durchzog das fastcgi Verbindung zu nginx werden.

+0

Leider unterdrückt das nur alle Protokolle von den Arbeitern. Sie werden nicht einmal in die PHP-Fehlerdatei eingefügt. – Gustavo

+0

Versuchen Sie, den Wert der Direktive error_log (make ist eine Datei, sagen wir _/var/log/php-fpm.www.log_) mit dem ursprünglichen Wert für 'catch_workers_output' zu ändern. – T0xicCode

+0

'error_log' wurde bereits festgelegt und funktioniert ordnungsgemäß. Ich habe den obigen Kommentar geschrieben, nachdem ich 'catch_workers_output' mit' yes' und 'no' getestet habe. Hier ist meine Konfigurationsdatei, btw: https://github.com/gnarea/docker-alpine-php-fpm/blob/0379fb6c1badd81c3bca3c39ed2de20d1c42c70e/php-fpm.conf – Gustavo