嘉善戮赘餐饮管理有限公司

中國站

中國站

國際版

聯(lián)系我們

400-002-9968

售前咨詢

售后服務

注冊 登錄
安全類
服務器管理面板
應用系統(tǒng)
首頁 > 在線幫助 >PHP FastCGI 模式運行出錯:Premature end of script headers

PHP FastCGI 模式運行出錯:Premature end of script headers

更新時間: 2022-06-14 10:27:50

適用版本:
Plesk Onyx for Linux
Plesk 12.5 for Linux
Plesk 12.0 for Linux
Plesk 11.x for Linux

問題
1. 將PHP模式切換為FastCGI時,一個secondary PHP 運行出錯:
# tailf /var/www/vhosts/domain.tld/logs/error_log
(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
Premature end of script headers: index.php

或出現(xiàn)下面的錯誤:
[fcgid:warn] [pid 1175:tid 140298957072128] (104)Connection reset by peer: [client xx.xx.xx.xx:50320] mod_fcgid: error reading data from FastCGI server
[core:error] [pid 1175:tid 140298957072128] [client xx.xx.xx.xx:50320] End of script output before headers: index.php
[fcgid:warn] [pid 1174:tid 140298982250240] (104)Connection reset by peer: [client xx.xx.xx.xx:50324] mod_fcgid: error reading data from FastCG

2. Apache日志顯示內存錯誤
# less /etc/httpd/logs/error_log
Apache/2.2.15 (Unix) DAV/2 mod_fcgid/2.3.7 mod_python/3.3.1 Python/2.6.6 mod_ssl/2.2.15 OpenSSL/1.0.0-fips SVN/1.6.11 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Errno 12] Cannot allocate memory

3. 系統(tǒng)日志顯示suhosin警告
# less /var/log/syslog
hosting suhosin[32242]: ALERT - zend_mm_head corrupted at 0x2e02420 (attacker '203.0.113.2', file '/var/www/vhosts/example.com/httpdocs/index.php')

4. Suexec日志顯示下面的錯誤:
# tailf /var/log/httpd/suexec_log
uid: (10033/ftpuser) gid: (504/504) cmd: cgi_wrapper
unknown error in docroot check (10033)

原因
1. PHP未使用FastCGI進行編譯。
2. 服務器上沒有足夠的內存。
3. 域名php.ini被自定義過,含有錯字,或有無效的配置。
4. /etc/passwd 文件的權限不正確。
5. 某個 php 模塊不兼容。

解決方案
1. 使用SSH連接服務器,確保使用FastCGIPHP進行編譯??梢允褂孟旅娴拿顧z查是否已啟用fastcgi模塊。
# /usr/local/psa/admin/bin/php_handlers_control --list
id:  display name:  version:    type:                                     cgi-bin:                php.ini:
fastcgi-5.2.17         5.2.17    5.2.17      cgi  /usr/local/php5.2.17/bin/php-cgi  /usr/local/lib/php.ini

檢查PHP版本:
# /usr/local/php5.2.17-cgi/bin/php-cgi -v
PHP 5.2.17 (cgi) (built: Mar 27 2014 20:28:44)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

如上所示,使用的是5.2.17 (cgi)。也就是說PHP只在CGI模式下運行。能夠同時在CGIFastCGI模式下運行PHP如下:
# php-cgi -v
PHP 5.3.3 (cgi-fcgi) (built: Jul 12 2013 20:34:01)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd.

如果未使用FastCGI模式編譯過PHP,請使用選項 --enable-fastcgi 重新編譯自定義 php。

2. 請使用下面的命令確保服務器上有足夠的內存:
# free -m

如果服務器是一個虛擬的容器,則可以使用下面的命令檢查資源限制:
# cat /proc/user_beancounters

3. 域名php.ini可能已被手動自定義過或包含某個錯誤。例如:將php.ini中的兆字節(jié)設置成了128MB而不是128M
備份原始的域名php.ini然后重新配置域名:
 # mv /var/www/vhosts/system/example.com/etc/php.ini /var/www/vhosts/system/example.com/etc/php.ini_orig

 # /usr/local/psa/admin/bin/httpdmng --reconfigure-vhost --vhost-name=example.com

對于Plesk 11.5和更高版本,請使用下面的命令:
 # /usr/local/psa/admin/bin/httpdmng --reconfigure-domain --domain-name=example.com

4. 請確保 /etc/passwd 文件有如下的權限:
# ls -la /etc/passwd
-rw-r--r-- 1 root root 7643 Mar  3 12:54 /etc/passwd

微信掃碼溝通
微信掃碼溝通

微信掃碼溝通

售前咨詢
合作
售后
return head