让 Nginx 中的致命错误显示在浏览器中

Kir*_*met 3 nginx web-server web

在开发过程中,每当我在 PHP 中因拼写错误或只是我的错误编程而创建致命错误时,我都会在浏览器中看到空白页面;)。对我来说,必须查看原始 nginx 错误日志文件来查看致命错误并找到它们所在的行号是非常烦人的。我似乎找不到如何让 nginx 在浏览器中显示 PHP 致命错误。这是我的 nginx 配置的相关部分:

location @fpm {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_NAME index.php;
    fastcgi_param SCRIPT_FILENAME $document_root/index.php;
    fastcgi_param PATH_INFO $path_info;
}
Run Code Online (Sandbox Code Playgroud)

这是一个错误示例,它显示在我的错误日志中,然后导致浏览器页面空白:

2014/01/04 14:53:52 [error] 20082#0: *403 FastCGI sent in stderr:
"PHP message: PHP Fatal error:  Cannot redeclare class ClassName in FilePath on line 356"
while reading response header from upstream, client: 192.168.1.10,
server: servername, request: "GET URLPATH HTTP/1.1",
upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "host",
referrer: "referer"
Run Code Online (Sandbox Code Playgroud)

这是我的 PHP 信息:

在此输入图像描述

这是我的 PHP-FPM 配置:

http://pastebin.com/QkCTbBYj

我的 PHP-FPM 池配置:

http://pastebin.com/TZfZ8d7G

还有我的 PHP-FPM php.ini:

http://pastebin.com/RsXRxduf

如果有人能够阐明我可以做些什么来让这些错误出现,我会很高兴!

小智 5

在 PHP-FPM 池配置中取消注释

463行php_flag[display_errors] = off

并将其更改为

php_flag[display_errors] = on

并且不要忘记重新启动 php-fpm