【问题标题】:Apache 2.2 PHP-FPM, php files receiving 403 forbidden in browserApache 2.2 PHP-FPM,浏览器中禁止接收 403 的 php 文件
【发布时间】:2014-09-19 03:02:27
【问题描述】:

我正在尝试将 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 并将其更改为 apache.apache(不确定是否有必要)。

我没有在我的任何虚拟主机声明中添加任何内容。所有其他文件都解析,只是不是 PHP。

非常感谢任何帮助。谢谢。

【问题讨论】:

    标签: apache php centos6 http-status-code-403 mod-fastcgi


    【解决方案1】:

    我能够解决这个问题。

    /etc/php-fpm.d/www.conf

    listen = /tmp/php5-fpm.sock
    

    重新启动 php-fpm,然后将 /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!

    【讨论】:

      【解决方案2】:

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

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

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

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

      【讨论】:

        猜你喜欢
        • 2015-08-23
        • 2014-11-24
        • 2016-03-25
        • 2012-07-17
        • 2013-06-07
        • 2014-08-03
        • 2010-12-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多