Apache-2.2

Apache + PHP 通過 FastCGI

  • November 7, 2012

我在嘗試通過 Apache 中的 FastCGI 執行 PHP 時遇到了一些問題。我已載入 FastCGI 模組,但在嘗試載入頁面時出現以下錯誤:

The requested URL /fastcgi/php54.fcgi/index.php was not found on this server.

在某處,似乎要執行的腳本被附加到執行檔中,沒有任何空格。這可能是問題所在嗎?下面我包含了我的 Apache 配置中的片段(希望這已經足夠了):

LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so

FastCgiIpcDir /var/run/fastcgi
AddHandler fastcgi-script .fcgi
FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300
AddType application/x-httpd-php .php
ScriptAlias /fastcgi/ /Library/WebServer/FCGI-Executables/

<Directory "/Library/WebServer/FCGI-Executables">
   Options +ExecCGI
   SetHandler fastcgi-script
   Order allow,deny
   Allow from all
<VirtualHost *:80>
   ServerName www.somedomain.com
   ServerAdmin admin@example.com
   DocumentRoot "/Web/www.somedomain.com"
   DirectoryIndex index.html index.php default.html
   CustomLog /var/log/apache2/access_log combinedvhost
   ErrorLog /var/log/apache2/error_log

   Action application/x-httpd-php /fastcgi/php54.fcgi

   <IfModule mod_ssl.c>
           SSLEngine Off
           SSLCipherSuite "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"
           SSLProtocol -ALL +SSLv3 +TLSv1
           SSLProxyEngine On
           SSLProxyProtocol -ALL +SSLv3 +TLSv1
   </IfModule>

   <Directory "/Web/www.somedomain.com">
           Options All -Indexes +ExecCGI +Includes +MultiViews
           AllowOverride All
           <IfModule mod_dav.c>
                   DAV Off
           </IfModule>
           <IfDefine !WEBSERVICE_ON>
                   Deny from all
                   ErrorDocument 403 /customerror/websitesoff403.html
           </IfDefine>
   </Directory>
</VirtualHost>

…這是執行檔:

#!/bin/sh

PHP_FCGI_CHILDREN=1
PHP_FCGI_MAX_REQUESTS=5000

export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS

exec /opt/local/bin/php-cgi54

原來我走錯了路:

ScriptAlias /fastcgi/ /Library/WebServer/FCGI-Executables/

本來應該

ScriptAlias /fastcgi/ /Library/Server/Web/Data/FCGI-Executables/

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