允许 Apache 2.2 中特定 VirtualHost 的目录查看/遍历

war*_*ren 3 virtualhost centos6 apache-2.2

我配置了以下虚拟主机:

<VirtualHost *:80>
    DocumentRoot /var/www/myvhost
    ServerName myv.host.com
    ServerAlias myv.host.com
    ErrorLog logs/myvhost-error_log
    CustomLog logs/myvhost-access_log combined
    ServerAdmin myv@host.com
    <Directory /var/www/myvhost>
        AllowOverride All
        Options +Indexes
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

从工具的角度来看,配置似乎是正确apachectl的。

但是,我无法在该虚拟主机上获得目录列表:

Forbidden

You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
Run Code Online (Sandbox Code Playgroud)

错误日志显示以下内容:

[Wed Mar 07 19:23:33 2012] [error] [client 66.6.145.214] Directory index forbidden by Options directive: /var/www/******
Run Code Online (Sandbox Code Playgroud)

更新2

最近,以下内容正在进入 error.log:

[Wed Mar 07 20:16:10 2012] [error] [client 192.152.243.233] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/error/noindex.html
Run Code Online (Sandbox Code Playgroud)

更新3

今天,以下内容被踢出:

[Thu Mar 08 14:05:56 2012] [error] [client 66.6.145.214] Directory index forbidden by Options directive: /var/www/<mydir>
[Thu Mar 08 14:05:56 2012] [error] [client 66.6.145.214] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/error/noindex.html
[Thu Mar 08 14:05:57 2012] [error] [client 66.6.145.214] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Run Code Online (Sandbox Code Playgroud)

这是在修改vhosts.conf文件之后:

<VirtualHost *:80>
    DocumentRoot /var/www/<mydir>
    ServerName myhost
    ServerAlias myhost
    ErrorLog logs/myhost-error_log
    CustomLog logs/myhost-access_log combined
    ServerAdmin admin@myhost
    <Directory "/var/www/<mydir>">
         Options All +Indexes +FollowSymLinks
         AllowOverride All
         Order allow,deny
         Allow from all
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

有什么不见了?

更新 4

根目录的所有子目录都正确地进行目录列表 -只有根目录不能。

use*_*517 7

403 表示正在找到资源。检查 apache 是否r-x对文档根目录及其上方的所有目录及其中r--的文件具有某种级别的权限。

尝试将您的目录指令更改为

<Directory /var/www/myvhost>
    AllowOverride All
    Options +Indexes
    Order allow,deny 
    Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)