Php
php-fpm 錯誤的文件描述符錯誤
我將 php-fpm 與客戶單獨的池一起使用。
有時頁面凍結,然後顯示 500 內部伺服器錯誤,並且我在錯誤日誌中收到此類錯誤:
[11-Feb-2013 22:12:39] ERROR: unable to read what child say: Bad file descriptor (9) [11-Feb-2013 22:12:39] ERROR: unable to read what child say: Bad file descriptor (9) [11-Feb-2013 22:12:42] WARNING: [pool oferty] child 31186 exited on signal 11 (SIGSEGV) after 198.250454 seconds from start
我目前的設置是:
[admin] listen = 127.0.0.1:51006 listen.backlog = -1 listen.allowed_clients = 127.0.0.1 user = admin group = admin pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 2 pm.max_requests = 1000 ;pm.status_path = /status ;ping.path = /ping ;ping.response = pong request_terminate_timeout = 180s request_slowlog_timeout = 180s 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] = 128M
應該增加什麼?我的伺服器使用 Intel Core i7 2600 3.4 GHz(8 個執行緒)+ 32 GB RAM,2xSSD 120 GB 軟體 RAID1 + 2x HDD 3 TB 軟體 RAID
增加:
pm.max_children = 20 pm.min_spare_servers = 2 pm.max_spare_servers = 4 request_terminate_timeout = 300s request_slowlog_timeout = 300s
所有問題都消失了;)
我設法通過更正日誌上的文件權限來解決此問題。
確保執行 php-fpm 的使用者可以讀寫配置的日誌文件。