【发布时间】:2017-07-05 23:20:04
【问题描述】:
我遇到了一个奇怪的行为。我正在使用 PHP-FPM 运行 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 的错误日志?目前它是一个或另一个。是否有可能克服这个问题?
【问题讨论】: