nginx php-fpm 子进程退出,代码为 0

nginx php-fpm 子进程退出,代码为 0

有人遇到过与 php-fpm 7 11.0-RELEASE-p8 类似的问题或知道如何调试它吗?

几分钟后,情况开始出现,只向客户显示一半页面。所有页面都显示约 62kb 的内容,结尾��������� 4.

php-fpm的日志文件:

[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80582 exited with code 0 after 0.005648 seconds from start
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80584 started
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80583 exited with code 0 after 0.005877 seconds from start
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80585 started
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80581 exited with code 0 after 0.007763 seconds from start
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80586 started
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80585 exited with code 0 after 0.005653 seconds from start
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80587 started
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80586 exited with code 0 after 0.005820 seconds from start
[18-Mar-2017 15:41:49] NOTICE: [pool www] child 80588 started

PHP配置:

$php -v
PHP 7.0.17 (cli) (built: Mar 17 2017 02:07:44) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.17, Copyright (c) 1999-2017, by Zend Technologies

PHP-FPM.conf

pm = dynamic
pm.max_children = 25
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 3
pm.max_requests = 0 ;changing to 500

答案1

首先,这是预期的行为。这些消息被标记为 NOTICE,这是 php-fpm.conf 中的默认设置:

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

当在 php-fpm 配置文件中定义 pm.max_requests 选项时,进程会退出并重新生成。

例如:

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500

如果在本例中定义为 500,则 php-fpm 在处理完 500 个请求后将重新开始该进程。实际上,您可以忽略这些消息,因为它们是无害的,只是信息性的。

如果您不想记录这些消息,只需将您的日志级别更改为高于的级别notice,例如warning

答案2

在代码中使用 exec 函数时会出现 php-fpm 错误。好的做法是阻止它们,这样就不会出现这样的问题。

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

该漏洞已存在四年了。

相关内容