Ubuntu服务器上的Apache 2.4.6:客户端被服务器configuration拒绝(PHP FPM)

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

而且我的Apache 2安装被破坏了。

在这里我的configuration:

文件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. 

我应该怎样解决它?

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

首先,我更改了/etc/apache2/conf-available/php5-fpm.conf 。 我取代了每一个

 Order Deny,Allow Deny from all 

 Require all granted 

configuration必须由a2enconf php5-fpm启用。 我对我的虚拟主机configuration也做了相同的replace。

我认为这不是出于安全原因而被build议的,但只要我使用我的服务器用于本地目的,我只能忍受它。

我遇到了一个新的安装Apache 2.4的确切问题。 经过几个小时的search和testing,我终于发现,我也必须允许访问包含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> 

我今天碰到类似的问题(但与mod_wsgi )。 这可能是一个Apache的2.2到2.4的问题。 在这里可以find一个全面的更改列表。

对我来说,它有助于为错误日志所抱怨的每个path添加一个额外的<Directory> -entry,并填写Require all granted

所以在你的情况下,你可以尝试

 <Directory /usr/lib/cgi-bin/php5-fcgi> Require all granted Options FollowSymLinks </Directory> 

我必须将我的configuration文件从文件夹conf.d移动到sites-enabled文件夹sites-enabled

总而言之,这对我来说是诀窍,但我不保证它也适用于您的情况。

我最近遇到了同样的问题。 我不得不改变我的虚拟主机:

 <VirtualHost *:80> ServerName local.example.com DocumentRoot /home/example/public <Directory /> Order allow,deny Allow from all </Directory> </VirtualHost> 

至:

 <VirtualHost *:80> ServerName local.example.com DocumentRoot /home/example/public <Directory /> Options All AllowOverride All Require all granted </Directory> </VirtualHost> 

apache2.conf ,replace或删除<Directory /> AllowOverride None Require all denied </ Directory>,就像Jan Czarnybuild议的那样。

例如:

 <Directory /> Options FollowSymLinks AllowOverride None #Require all denied Require all granted </Directory> 

这在Ubuntu 14.04 (Trusty Tahr)工作。

你的虚拟主机文件名应该是mysite.com.conf,并且应该包含这个信息

 <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName mysite.com ServerAlias www.mysite.com ServerAdmin info@mysite.com DocumentRoot /var/www/mysite # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, eg #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory "/var/www/mysite"> Options All AllowOverride All Require all granted </Directory> # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

我不认为用这个指令replace“要求所有被拒绝”:

 <Directory> Options FollowSymLinks AllowOverride None #Require all denied Require all granted </Directory> 

正如Jan Czarny所build议的那样,user3801675是解决这个问题的最安全的方法。

根据Apacheconfiguration文件,该行拒绝访问整个服务器的文件系统。 replace它可能确实允许访问您的虚拟主机文件夹,但也允许访问您的整个计算机!

Gev Balyan的方法似乎是这里最安全的方法。 这是今天早上build立我的新Apache服务器后,“拒绝访问的问题”的答案。

而我只是得到这个错误,因为我使用了一个完全不同的DocumentRoot目录。

我的主DocumentRoot是默认的/var/www/html ,在我使用/sites/example.com的VirtualHost上

我在/var/www/html/example.com (到/sites/example.com )上创build了一个链接。 DocumentRoot被设置为/var/www/html/example.com

它像一个魅力工作。

对于那些在AWS(amazon web services)上的用户,请记住为您的SSL端口(在我的情况下为443)添加一个规则到您的安全组。 我得到这个错误,因为我忘了打开端口。

3个小时后把我的头发撕掉…