我正在尝试将 php 从 fcgid 切换到 fpm。我已经用谷歌搜索到了这个结果,虽然有些问题看起来相同,但我仍然无法解决它。
我正在运行 CentOS 6.5、Apache 2.2、PHP 5.4。我安装了 mod_fastcgi 和 php-fpm。 PHP 正在 shell 中运行,但我通过浏览器收到 403 错误。显然,Apache 没有正确传递请求。安装后,我进行了以下更改:
将/etc/httpd/conf.d/fcgid.conf 重命名为 fcgid.conf.disabled
将以下内容添加到/etc/httpd/conf.d/fastcgi.conf
<IfModule mod_fastcgi.c>
DirectoryIndex index.html index.shtml index.cgi index.php
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass$
<Directory "/usr/lib/cgi-bin">
Order allow,deny
<Files "php5.fastcgi">
Order deny,allow
</Files>
</Directory>
</IfModule>
我还创建了目录/usr/lib/cgi-bin 并将其 chown 到 apache.apache(不确定这是否有必要)。
我没有在任何虚拟主机声明中添加任何内容。所有其他文件都可以解析,但 PHP 除外。
非常感谢任何帮助。谢谢。
最佳答案
我能够解决这个问题。
/etc/php-fpm.d/www.conf
listen = /tmp/php5-fpm.sock
重新启动 php-fpm,然后 chown'd/tmp/php5-fpm.sock 到 apache.apache
/etc/httpd/conf.d/fastcgi.conf
<IfModule mod_fastcgi.c>
DirectoryIndex index.php index.html index.shtml index.cgi
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization
# For monitoring status with e.g. Munin
<LocationMatch "/(ping|status)">
SetHandler php5-fcgi-virt
Action php5-fcgi-virt /php5-fcgi virtual
</LocationMatch>
最后,将我的浏览器指向/info.php 和服务器 API:FPM/FastCGI!
关于Apache 2.2 PHP-FPM,浏览器中禁止接收 403 的 php 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24986537/