Apache“客户端被服务器configuration拒绝”,尽pipe允许访问目录(虚拟主机configuration)

在Ubuntu上的Apache我已经build立了一个虚拟主机,但在浏览器中我一直得到一个“403访问被禁止”的错误; 日志说“ 客户端被服务器configuration拒绝:/ home / remix / ”。

在网上寻找解决scheme,我发现了许多关于目录访问的post(允许所有等),但据我所知,我已经这样做了。 在httpd-vhosts.conf中有以下代码:

NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/opt/lampp/htdocs/" ServerName localhost ServerAlias localhost ErrorLog "logs/dummy-host.example.com-error_log" CustomLog "logs/dummy-host.example.com-access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot "/home/remix/" ServerName testproject ServerAlias testproject <Directory "/home/remix/"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> 

我也补充说

 127.0.0.1 testproject 

到/ etc / hosts文件。

此外,/ home / remix /文件夹包含一个index.html文件,在httpd.conf中启用了vhosts。

有什么我没有看到?

编辑:这是Apache的error_log条目:

 [Sat Aug 18 09:15:32.666938 2012] [authz_core:error] [pid 6587] [client 127.0.0.1:38873] AH01630: client denied by server configuration: /home/remix/ 

    更改您的授权configuration:

     <Directory /home/remix/> #... Order allow,deny Allow from all </Directory> 

    …到相同的Apache 2.4版本。

     <Directory /home/remix/> #... Require all granted </Directory> 

    查看升级的概述文档 ,了解您可能需要做的其他更改的信息,同时请注意,您在Google(以及本站点)上find的大部分configuration示例和帮助都是指2.2。

    确保运行httpd服务的用户可以访问这个目录。

    检查目录上的权限。 我敢打赌,除了你自己之外,它将被禁止访问任何人,例如:

     $ ls -ld /home/remix drwx------ 92 remix remix 4096 Aug 17 22:59 /home/remix 

    如果你确切地看到drwx------ ,那么情况就是这样。 修复它通过运行:

     chmod a+x /home/remix 

    “被服务器configuration拒绝的客户端”意味着Linux服务器本身禁止访问文件,而不是Apache。

    如果通过更改权限/所有权/组成员身份提供访问权限并不能解决问题,则路由原因可能是SELinux禁止访问任何不具有相应SE Linux上下文的文件夹,如“在Selinux下重新定位Apache DocumentRoot”中所述 。

    • 如果通过执行setenforce 0临时禁用SELinux,则会使文件可访问
    • 而重新启用SELinux做setenforce 0再次使文件无法访问

    那么无论文件权限如何,SELinux都会禁止访问。