【问题标题】:NGINX / PHP7.4-FPM throws 502 without error_reporting enabledNGINX / PHP7.4-FPM 在没有启用错误报告的情况下抛出 502
【发布时间】:2020-09-25 14:48:12
【问题描述】:

昨天我偶然发现了一个奇怪的问题。突然一个特定的 PHP 脚本不再工作了,它抛出了 502 错误。当我启用 error_reporting 时,只显示通知/警告,但页面的其余部分正在正确呈现。当我再次禁用error_reporting("E_ALL"); ini_set("display_errors", 1); 时,NGINX 再次抛出 502。

奇怪的是,当我使用以下 sn-p 捕获通知/警告时:

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
    if ($errno == E_USER_NOTICE){
    }
}

set_error_handler("myErrorHandler");

页面也正确呈现,显然没有显示错误。

Debian 版本:4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64

PHP版本:php7.4-fpm

NGINX 版本:nginx/1.10.3

这可能是内存问题吗?或者有人有其他解释,为什么会这样?

代码没有设置响应标头,因为我从未在某处设置任何标头。我也不使用错误处理程序,我只是在某些东西不起作用时激活 error_reporting。如果一切正常,我将禁用 display_errors,因此不会显示通知/警告。

如果我删除文件的以下行,它也可以在不捕获错误的情况下工作: $list = $tn->getMassnahmen();

$tn 是我的类 'teilnehmer' 的一个实例: $tn = new teilnehmer;

'getMassnahmen' 的代码:

    function getMassnahmen()
    {
        $stmt = $this->db->prepare('SELECT * FROM `massnahmen_txt` ORDER BY `id` ASC');
        if ($stmt->execute()) {
            while ($row = $stmt->fetch()) {
                $result[] = $row;
            }
        }

        return $result;
    }

'teilnehmer' 是我的客户。客户端可以添加文件(不同的数据库表)。只有在客户端添加了文件时,才会以某种方式出现错误。如果我在我的代码中注释掉有关文件的整个部分,错误仍然会发生。只有删除$list = $tn->getMassnahmen(); 行会有帮助。但是这条线与文件没有任何关系。他们只使用同一个类。

'teilnehmer' ($tn) 的类/实例之前在代码中被多次使用,没有任何错误。

错误日志:

Notice:  Undefined variable: nocal in /PATH//html/inc/global.inc.php on line 34
Notice:  Undefined variable: result in /PATH//html/classes/user.php on line 672
Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 57
Notice:  Undefined variable: newdates in /PATH//html/inc/global.inc.php on line 101
Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 101
Notice:  Undefined variable: list in /PATH//html/inc/global.inc.php on line 113
Notice:  Undefined variable: is_index in /PATH//html/inc/global.inc.php on line 120
Notice:  Undefined variable: result in /PATH//html/classes/user.php on line 898
Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 129
Notice:  Undefined variable: calendar in /PATH//html/inc/global.inc.php on line 133
Notice:  Undefined variable: result in /PATH//html/classes/user.php on line 898
Notice:  Undefined variable: result in /PATH//html/classes/mandanten.php on line 48
Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 144
Notice:  Undefined variable: result in /PATH//html/classes/user.php on line 1425
Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 190
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning:  array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Notice:  Undefined index: success in /PATH//html/teilnehmer_edit.php on line 17
Notice:  Undefined index: removedfile in /PATH//html/teilnehmer_edit.php on line 21
Notice:  Undefined index: successremovelog in /PATH//html/teilnehmer_edit.php on line 26
Notice:  Undefined index: fehltag_add in /PATH//html/teilnehmer_edit.php on line 65
Notice:  Undefined index: remove_fehltag in /PATH//html/teilnehmer_edit.php on line 142
Notice:  Undefined variable: content in /PATH//html/teilnehmer_edit.php on line 248
Notice:  Undefined variable: active_fehltage in /PATH//html/teilnehmer_edit.php on line 257
Notice:  Undefined variable: kursdata in /PATH//html/teilnehmer_edit.php on line 281
Notice:  Undefined variable: statusdata in /PATH//html/teilnehmer_edit.php on line 282
Notice:  Undefined variable: tabledata in /PATH//html/classes/template.php on line 134
Notice:  Undefined variable: result in /PATH//html/classes/teilnehmer.php on line 606
Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/teilnehmer_edit.php on line 300
Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/teilnehmer_edit.php on line 314
Notice:  Undefined variable: filelist in /PATH//html/teilnehmer_edit.php on line 387
Notice:  Undefined variable: fehlliste in /PATH//html/teilnehmer_edit.php on line 676
Notice:  Trying to access array offset on value of type bool in /PATH//html/teilnehmer_edit.php on line 699
Notice:  Undefined variable: aglist in /PATH//html/teilnehmer_edit.php on line 740
Notice:  Undefined index: name in /PATH//html/teilnehmer_edit.php on line 742
Notice:  Undefined index: name in /PATH//html/teilnehmer_edit.php on line 742
Notice:  Undefined variable: result in /PATH//html/classes/teilnehmer.php on line 684
Warning:  sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/teilnehmer_edit.php on line 752
Notice:  Undefined variable: list1 in /PATH//html/teilnehmer_edit.php on line 776
Notice:  Undefined variable: mlist in /PATH//html/teilnehmer_edit.php on line 796

提前感谢您的帮助!

【问题讨论】:

  • 我们需要更多信息/代码来完全回答这个问题。它可能是您的默认错误处理程序,可能是代码中的某些响应标头设置为 503。请提供更多信息
  • 我已经编辑了我的主要帖子。谢谢!
  • 最后一件事会很有帮助,当你用 sn-p 捕获错误时,你能打印出来吗?也许那些会有很好的信息。
  • 我已将错误日志添加到主帖中。此外,我已经更正了错误代码。 NGINX 抛出 502 而不是 503。
  • 我怀疑发生了超时,你可以设置set_time_limit(0) 并在 nginx 中将超时配置为较高的值。

标签: php nginx error-reporting fpm


【解决方案1】:

设置后

fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;

在我的 nginx 配置中,问题已解决。似乎 fastcgi 的缓冲区大小不足以响应响应。非常感谢您的帮助!

【讨论】:

    猜你喜欢
    • 2020-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-15
    • 2023-04-04
    • 2014-10-17
    • 2011-04-06
    相关资源
    最近更新 更多