【问题标题】:Getting Fatal Errors in Nginx to Be Shown in the Browser在浏览器中显示 Nginx 中的致命错误
【发布时间】:2014-01-22 13:08:06
【问题描述】:

编辑:

我已完成重复答案中建议的所有操作,但没有任何效果。这是我的 PHP 信息:

这是 nginx 和 stderr 消息的特定问题,而不是一般的“我如何打开 PHP 错误报告”问题。


在开发过程中,每当我在 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;
}

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

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"

这是我的 PHP-FPM 配置文件:

http://pastebin.com/QkCTbBYj

还有我的 PHP-FPM 池配置:

http://pastebin.com/TZfZ8d7G

还有我的 PHP-FPM php.ini:

http://pastebin.com/RsXRxduf

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

【问题讨论】:

标签: nginx development-environment php


【解决方案1】:

尝试在池配置中将 catch_workers_output 设置为 yes:

;将工作人员标准输出和标准错误重定向到主错误日志。如果未设置,stdout 和 ;根据 FastCGI 规范,stderr 将被重定向到 /dev/null。 ;注意:在高负载环境中,这可能会导致页面出现一些延迟 ;处理时间(几毫秒)。 ;默认值:无 catch_workers_output = 是的

如果这不起作用,您可能会遇到此错误:

https://bugs.php.net/bug.php?id=61045

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-06
    • 2015-02-17
    • 2013-01-02
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 2011-06-30
    • 2022-08-06
    相关资源
    最近更新 更多