Php

php 腳本在 30 秒後被殺死並拋出內部伺服器錯誤

  • February 18, 2013

我在我的伺服器上使用 php_fpm_event,執行 30 秒後,程序被終止,我看到內部伺服器錯誤。

但是我設置了更大的值:

[admin]
listen = 127.0.0.1:57797
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = admin
group = admin
pm = dynamic
pm.max_children = 30
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 6
pm.max_requests = 1000
;pm.status_path = /status
;ping.path = /ping
;ping.response = pong
request_terminate_timeout = 300s
request_slowlog_timeout = 300s
slowlog = /var/log/php-fpm/slow.log
rlimit_files = 1024
rlimit_core = 0
;chroot =
;chdir = /var/www
catch_workers_output = yes
security.limit_extensions = .php .php3 .php4 .php5

env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f webmaster@domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/error.log
php_admin_value[session.save_path] = /var/lib/php/session
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 256M

Phpinfo 確認 execution_time 為 300 秒。那麼為什麼會這樣呢?

5分鐘後,我得到了這樣的日誌:

[17-Feb-2013 22:35:36] WARNING: [pool admin] child 7308, script '/home/admin/nowosci.org/td/odpal.php' (request: "GET /td/odpal.php") executing too slow (306.607536 sec), logging
[17-Feb-2013 22:35:44] WARNING: [pool admin] child 7308, script '/home/admin/nowosci.org/td/odpal.php' (request: "GET /td/odpal.php") execution timed out (313.981994 sec), terminating
[17-Feb-2013 22:35:44] WARNING: [pool admin] child 7308 exited on signal 15 (SIGTERM) after 679.176797 seconds from start

為什麼它在 30 秒後顯示內部伺服器錯誤?

我找到了答案:

FastCGIExternalServer "/home/admin/nowosci.org/nowosci.org.0fake" -host 127.0.0.1:57797

雖然應該有

FastCGIExternalServer "/home/admin/nowosci.org/nowosci.org.0fake" -host 127.0.0.1:57797 -idle-timeout 300

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