![通过 FastCGI 的 Apache + PHP](https://linux22.com/image/796663/%E9%80%9A%E8%BF%87%20FastCGI%20%E7%9A%84%20Apache%20%2B%20PHP.png)
我在尝试通过 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 [email protected]
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
答案1
事实证明我走错了路:
ScriptAlias /fastcgi/ /Library/WebServer/FCGI-Executables/
本来应该
ScriptAlias /fastcgi/ /Library/Server/Web/Data/FCGI-Executables/