php 5.4.7 通过 mod_fcgi
当我运行该网站时,有时它可以正常工作,有时它会崩溃并出现 500 内部错误,这是我每次运行脚本时在 error.log 中看到的内容
[Mon Sep 24 18:50:43 2012] [warn] [client 68.231.194.198] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Mon Sep 24 18:50:43 2012] [error] [client 68.231.194.198] Premature end of script headers: api.php
有任何想法吗?
虚拟主机配置:
<VirtualHost :80>
ServerAdmin [email protected]
DocumentRoot "/home/www/sites/test.com/html/development"
ServerName test.com
ServerAlias www.test.com
ErrorLog "/home/www/sites/test.com/logs/error_log"
CustomLog "/home/www/sites/test.com/logs/access_log" common
<IfModule mod_fcgid.c>
<Directory /home/www/sites/test.com/html/development>
Options +ExecCGI
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /home/www/php-fcgi-scripts/php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
FcgidMaxRequestLen 1073741824
</VirtualHost>
fcgi.d 配置
LoadModule fcgid_module modules/mod_fcgid.so
# Use FastCGI to process .fcg .fcgi & .fpl scripts
AddHandler fcgid-script fcg fcgi fpl
# Sane place to put sockets and shared memory file
FcgidIPCDir /var/run/mod_fcgid
FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm
IdleTimeout 300
BusyTimeout 300
ProcessLifeTime 7200
IPCConnectTimeout 300
IPCCommTimeout 7200
PHP_Fix_Pathinfo_Enable 1
php-fcgi-启动器.php
#!/bin/sh
PHP_CGI=/usr/local/php547/bin/php-cgi
PHP_INI=/etc/php547-fastcgi.ini
export PHP_FCGI_TIMEOUT=1200
#export PHP_FCGI_CHILDREN=6
export PHP_FCGI_MAX_REQUESTS=1000
exec $PHP_CGI -c $PHP_INI
答案1
事实证明,PHP 5.4.7 与最新的 APC 模块配合得不好。我在 php547-fastcgi.ini 中禁用了它 - 一切又开始正常工作