Apache-2.2

CentOS 5.5、Apache2.2、PHP 5.2.14、Fastcgi 2.2-4 和 5xx 錯誤

  • January 26, 2011

我正在執行主題中提到的軟體版本。Apache 是從標準 centos repo 安裝的,fastcgi 是從http://centos.karan.org/kbsingh-CentOS-Extras.repo安裝的,而 PHp 是手動編譯並安裝到 /usr/local/php5-fastcgi 的。

當我嘗試訪問諸如http://vantagefx.com/affiliate/merchants/之類的 URL 時,我不斷收到 5xx 伺服器錯誤(而且我沒有使用 suexec 順便說一句)。

虛擬主機

<VirtualHost x.x.x:80>
   ServerAdmin webmaster@example.com
   ServerName example.com
   ServerAlias www.example.com


   DocumentRoot /var/www/html
   <Directory /var/www/html/>

           Options Indexes FollowSymLinks
           AllowOverride All


           Order allow,deny
           Allow from all

   </Directory>



   <IfModule mod_fcgid.c>
               <Directory /var/www/html/php530-files/>
                         Options +ExecCGI
                         AllowOverride All
                         AddHandler fcgid-script .php
                         FCGIWrapper /var/www/php-fcgi-scripts/php-fcgi-starter .php

                         Order allow,deny
                         Allow from all
               </Directory>
     </IfModule>

/var/www/php-fcgi-scripts/php-fcgi-starter

#!/bin/sh
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=8
exec /usr/local/php5-fcgi/bin/php -c /etc/php.ini

錯誤日誌

[Wed Sep 08 02:39:25 2010] [notice] mod_fcgid: process /var/www/html/php530-files/scripts/imp.php(2319) exit(communication error), terminated by calling exit(), r5
[Wed Sep 08 02:39:30 2010] [notice] mod_fcgid: call /var/www/html/php530-files/scripts/imp.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 02:39:31 2010] [notice] mod_fcgid: call /var/www/html/php530-files/scripts/imp.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 02:39:32 2010] [notice] mod_fcgid: call /var/www/html/php530-files/scripts/imp.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 02:39:33 2010] [notice] mod_fcgid: call /var/www/html/php530-files/scripts/imp.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 02:39:33 2010] [notice] mod_fcgid: process /var/www/html/php530-files/scripts/imp.php(2340) exit(communication error), terminated by calling exit(), r5
[Wed Sep 08 02:39:33 2010] [notice] mod_fcgid: process /var/www/html/php530-files/scripts/imp.php(2335) exit(communication error), terminated by calling exit(), r5
[Wed Sep 08 02:39:33 2010] [notice] mod_fcgid: process /var/www/html/php530-files/scripts/imp.php(2334) exit(communication error), terminated by calling exit(), r5
[Wed Sep 08 02:39:37 2010] [notice] mod_fcgid: process /var/www/html/php530-files/scripts/imp.php(2341) exit(communication error), terminated by calling exit(), r5
[Wed Sep 08 02:39:42 2010] [notice] mod_fcgid: call /var/www/html/php530-files/scripts/imp.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 02:39:43 2010] [notice] mod_fcgid: call /var/www/html/php530-files/scripts/imp.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 02:39:44 2010] [notice] mod_fcgid: call /var/www/html/php530-files/scripts/imp.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 02:39:45 2010] [notice] mod_fcgid: call /var/www/html/php530-files/scripts/imp.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 02:39:45 2010] [notice] mod_fcgid: process /var/www/html/php530-files/scripts/imp.php(2364) exit(communication error), terminated by calling exit(), r5
[Wed Sep 08 02:39:45 2010] [notice] mod_fcgid: process /var/www/html/php530-files/scripts/imp.php(2359) exit(communication error), terminated by calling exit(), r5

和:

[Wed Sep 08 09:49:05 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:06 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:07 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:16 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:17 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:18 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:19 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:28 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:29 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:30 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:31 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:35 2010] [warn] mod_fcgid: can't apply process slot for /var/www/html/affiliate/phpinfo.php
[Wed Sep 08 09:49:40 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:41 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:42 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:43 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:52 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:53 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:54 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:49:55 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.
[Wed Sep 08 09:50:05 2010] [warn] (104)Connection reset by peer: mod_fcgid: read data from fastcgi server error.

如果我手動執行程式碼

/usr/local/php5-fcgi/bin/php /var/www/html/php530-files/scripts/imp.php 

它執行得很好,沒有錯誤,沒有警告,沒有通知。

$$ EDIT $$ PHP 程序

ps aux | grep php
apache   22494  1.5  0.0      0     0 ?        Z    08:16   0:00 [php] <defunct>
root     22500  0.0  0.0  61168   728 pts/0    S+   08:16   0:00 grep php

我還在 php530-files 目錄中創建了一個 phpinfo.php 並嘗試訪問它,仍然沒有運氣,503 Service Unavailable 並且日誌是:

[Wed Sep 08 08:27:45 2010] [notice] mod_fcgid: call /var/www/html/php530-files/phpinfo.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter
[Wed Sep 08 08:27:46 2010] [notice] mod_fcgid: call /var/www/html/php530-files/phpinfo.php with wrapper /var/www/php-fcgi-scripts/php-fcgi-starter

看,這個過程沒有因為任何通信錯誤等而終止,但我仍然收到 5xx 錯誤。

權限

[root@www php530-files]# ls -l
total 35604
drwxrwxr-x  3 apache vfx_affil     4096 Sep  8 03:41 accounts
drwxrwxr-x  4 apache vfx_affil     4096 Sep  8 03:42 affiliates
drwxrwxr-x  2 apache vfx_affil     4096 Sep  8 03:41 api
-rw-rw-r--  1 apache vfx_affil      247 Sep  8 03:41 CHANGELOG.txt
drwxrwxr-x 11 apache vfx_affil     4096 Sep  8 03:41 include
-rw-rw-r--  1 apache vfx_affil     2203 Sep  8 03:41 index.html
drwxrwxr-x  9 apache vfx_affil     4096 Sep  8 03:41 install
-rw-rw-r--  1 apache vfx_affil      185 Sep  8 03:42 INSTALL.txt
-rw-rw-r--  1 apache vfx_affil     7643 Sep  8 03:41 LICENSE.txt
drwxrwxr-x  3 apache vfx_affil     4096 Sep  8 03:41 merchants
-rw-rw-r--  1 apache vfx_affil 36340881 Sep  8 03:41 pap_4.5.19.2.zip
-rw-r--r--  1 apache vfx_affil       20 Sep  8 08:23 phpinfo.php
drwxrwxr-x 52 apache vfx_affil     4096 Sep  8 03:42 plugins
-rw-rw-r--  1 apache vfx_affil     1008 Sep  8 03:41 README.txt
drwxrwxr-x  2 apache vfx_affil     4096 Sep  8 03:41 samples_tests
drwxrwxr-x  3 apache vfx_affil     4096 Sep  8 03:50 scripts
-rw-r--r--  1 apache vfx_affil       31 Sep  8 08:27 test.php
-rw-rw-r--  1 apache vfx_affil      371 Sep  8 03:41 UPDATE.txt
[root@www affiliate]# ls -l /var/www/php-fcgi-scripts/
total 4
-rwxrwxr-x 1 apache vfx_affil 203 Sep  8 03:39 php-fcgi-starter

找到了!在我的情況下,我在 /var/www/php-fcgi-scripts/php-fcgi-starter 中使用了錯誤的 php 二進製文件,它應該是 php-cgi。

像魅力一樣工作:

#!/bin/sh
PHP_CGI=/usr/local/php5-fcgi/bin/php-cgi
PHP_INI=/etc/php-fastcgi.ini
export PHP_FCGI_TIMEOUT=1200
export PHP_FCGI_CHILDREN=10
export PHP_FCGI_MAX_REQUESTS=1000
exec $PHP_CGI -c $PHP_INI

/var/www/php-fcgi-scripts/php-fcgi-starter可執行的,它和它所在的目錄是否由 Web 伺服器使用者擁有?

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