我遇到了一种奇怪的行为。我正在使用PHP运行NGINX。
当我在php.ini中启用PHP错误日志时
error_log = /var/www/logs/php-scripts.error.log
log_errors = on错误日志按预期写入:
...
[15-Feb-2017 19:35:28 Etc/UTC] PHP Parse error: syntax error, unexpected end of file, expecting ',' or ';' in /var/www/html/index.php on line 7但是,同时,在我的NGINX vhost 中配置的错误日志没有写入所有(这是NGINX配置片段):
server {
listen 80;
server_name vhost.com;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log; <- this is always empty
}现在让我惊讶的是,当我在php.ini中禁用错误日志时
; error_log = /var/www/logs/php-scripts.error.log <-- commented out
log_errors = on将NGINX错误日志写入。
...
2017/02/16 12:01:44 [error] 13#13: *27 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected end of file, expecting ',' or ';' in /var/www/html/index.php on line 7" while reading response header from upstream, client: 172.19.0.2, server: domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://172.19.0.3:9000", host: "domain.com:8080"我一点也不明白这种行为。这两个测井系统之间干扰的来源是什么?为什么不能在php.ini中启用错误日志,同时将NGINX的错误日志写入其中?现在不是一个就是另一个。是否有可能克服这个问题?
发布于 2017-02-16 18:30:54
PHP向日志文件syslog(3)或stderr报告错误,具体取决于是否设置和如何设置error_log。详情请参见本文件。
nginx将记录它在FastCGI stderr流上接收到的消息。
所以,这并不是真正奇怪的行为。
https://stackoverflow.com/questions/42280862
复制相似问题