Nginx

nginx php-fpm child 以程式碼 0 退出

  • March 11, 2019

任何人都對帶有 11.0-RELEASE-p8 的 php-fpm 7 有類似的問題,或者知道如何調試它?

幾分鐘後情況開始,僅向客戶顯示半頁。任何頁面都會顯示約 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

在程式碼中使用 exec 函式時,這是 php-fpm 錯誤。好的做法是阻止它們,這樣就不會出現這樣的問題。

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

錯誤在過去 4 年內開放。

首先,這是預期的行為。這些消息被標記為 NOTICE,這是 php-fpm.conf 中的預設值:

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

當 pm.max_requests 選項在您的 php-fpm 配置文件中定義時,程序正在退出並重新生成。

例如:

; 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.

引用自:https://serverfault.com/questions/839135