Apache-2.2

mod_fcgi 產生隨機 500 錯誤

  • September 25, 2012

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 admin@saritasa.com
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-starter.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

原來 PHP 5.4.7 不能很好地與最近的 APC 模組一起工作。我在 php547-fastcgi.ini 中禁用了它-一切都開始正常工作

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