Apache 2.2 PHP-FPM,php文件在浏览器中禁止403禁止

问题描述 投票:1回答:2

我正在尝试将php从fcgid切换到fpm。我已经用Google搜索到了这一点,虽然有些问题看起来一样,但我还是无法解决它。

我正在运行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。

任何帮助是极大的赞赏。谢谢。

apache php centos6 http-status-code-403 mod-fastcgi
2个回答
1
投票

我能够解决这个问题。

/etc/PHP-分排名.的/呜呜呜.conf

listen = /tmp/php5-fpm.sock

重新启动php-fpm,然后chown'd /tmp/php5-fpm.sock到apache.apache

/etc/HTTP的/conf.的/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和Server API:FPM / FastCGI!


0
投票

这与您可能需要设置目录权限的apache中的目录级权限相关,您需要授予Web服务器访问Web服务器的文件系统的权限。

以下是您可能需要在httpd.conf文件中添加的指令。

<Directory "/var/www/html">
 AllowOverride None
</Directory>

然后重新启动您的apache服务,这将解决您的问题。

© www.soinside.com 2019 - 2024. All rights reserved.