Ubuntu Server 上的 Apache 2.4.6:客户端被服务器配置 (PHP FPM) 拒绝 [加载 PHP 文件时]

2022-08-30 08:56:24

今天我更新了Ubuntu服务器13.04(Raring Ringtail)→13.10(Saucy Salamander)。

我的Apache 2安装坏了。

这是我的配置:

文件error.log

[Fri Oct 18 10:48:07.237170 2013] [:notice] [pid 8292:tid 139804677900160] FastCGI: process manager initialized (pid 8292)
[Fri Oct 18 10:48:07.241185 2013] [mpm_event:notice] [pid 8289:tid 139804677900160] AH00489: Apache/2.4.6 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 configured -- resuming normal operations
[Fri Oct 18 10:48:07.241652 2013] [core:notice] [pid 8289:tid 139804677900160] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 18 10:48:28.313923 2013] [authz_core:error] [pid 8294:tid 139804573181696]   [client 81.219.59.75:3536] AH01630: client denied by server configuration: /usr/lib/cgi-bin/php5-fcgi

文件default.conf

#EU
<VirtualHost *:80>
    #ServerName
    DocumentRoot /var/www/dev_stable

    DirectoryIndex index.php index.html index.htm

    <Directory /var/www/dev_stable>
          Options Indexes FollowSymLinks MultiViews

          AllowOverride all
          Require all granted
    </Directory>
</VirtualHost>

文件mods-enabled/fastcgi.conf

#<IfModule mod_fastcgi.c>
#  AddHandler fastcgi-script .fcgi
# FastCgiWrapper /usr/lib/apache2/suexec
#  FastCgiIpcDir /var/lib/apache2/fastcgi
#</IfModule>


<IfModule mod_fastcgi.c>
    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 /var/run/php5-fpm.sock -pass-header Authorization
</Ifmodule>

当我尝试通过浏览器加载文件时,我得到了:

site_name/TEST/

Forbidden

You don't have permission to access /php5-fcgi/TEST/index.php on this server.

我应该怎么解决它?


答案 1

我有完全相同的问题。我在本地计算机上运行了几个虚拟主机进行开发。

首先,我改变了.我更换了每一个/etc/apache2/conf-available/php5-fpm.conf

Order Deny,Allow
Deny from all

Require all granted

必须通过 启用配置。我对虚拟主机配置执行了相同的操作,并进行了替换。a2enconf php5-fpm

出于安全原因,我认为不建议这样做,但是只要我将服务器用于本地目的,只有我可以忍受它。


答案 2

我在重新安装Apache 2.4时遇到了这个确切的问题。经过几个小时的谷歌搜索和测试,我终于发现我还必须允许访问包含Alias指令的(不存在的)目标的目录。也就是说,这对我有用:

# File: /etc/apache2/conf-available/php5-fpm.conf
<IfModule mod_fastcgi.c>
    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 /var/run/php5-fpm.sock -pass-header Authorization

    # NOTE: using '/usr/lib/cgi-bin/php5-cgi' here does not work,
    #   it doesn't exist in the filesystem!
    <Directory /usr/lib/cgi-bin>
        Require all granted
    </Directory>
</Ifmodule>

推荐