为什么Apache会禁止我访问此页面?

为什么Apache会禁止我访问此页面?,apache,Apache,直到最近,内部Bugzilla安装工作正常。现在,所有对http://example.com/bugzilla目录返回403/禁止。该目录之外的页面,例如http://example.com/test.html或http://example.com/test/index.html按预期工作。这是bugzilla目录的.htaccess文件,与原始目录相同: # Don't allow people to retrieve non-cgi executable files or our priva

直到最近,内部Bugzilla安装工作正常。现在,所有对
http://example.com/bugzilla
目录返回
403/禁止
。该目录之外的页面,例如
http://example.com/test.html
http://example.com/test/index.html
按预期工作。这是
bugzilla
目录的
.htaccess
文件,与原始目录相同:

# Don't allow people to retrieve non-cgi executable files or our private data

<FilesMatch (\.pm|\.pl|\.tmpl|localconfig.*)$>
  deny from all
</FilesMatch>

<IfModule mod_expires.c>
    <IfModule mod_headers.c>
        <IfModule mod_env.c>
          <FilesMatch (\.js|\.css)$>
            ExpiresActive On
            # According to RFC 2616, "1 year in the future" means "never expire".
            # We change the name of the file's URL whenever its modification date
            # changes, so browsers can cache any individual JS or CSS URL forever.
            # However, since all JS and CSS URLs involve a ? in them (for the changing
            # name) we have to explicitly set an Expires header or browsers won't
            # *ever* cache them.
            ExpiresDefault "now plus 1 years"
            Header append Cache-Control "public"
          </FilesMatch>

          # This lets Bugzilla know that we are properly sending Cache-Control
          # and Expires headers for CSS and JS files.
          SetEnv BZ_CACHE_CONTROL 1
        </IfModule>
    </IfModule>
</IfModule>

AddHandler cgi-script .cgi .pl
DirectoryIndex index.cgi
这是站点的Apache配置文件:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/default/public_html
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/default/public_html>
        DirectoryIndex index.cgi
        AllowOverride Limit FileInfo Indexes
        AddHandler cgi-script .cgi
        Options Indexes FollowSymLinks MultiViews +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

服务器管理员webmaster@localhost
DocumentRoot/var/www/default/public\u html
选项如下符号链接
不允许超限
DirectoryIndex.cgi
AllowOverride限制文件信息索引
AddHandler cgi script.cgi
选项索引遵循SYMLINKS多视图+ExecCGI-多视图+SymLinksIfOwnerMatch
命令允许,拒绝
通融
ScriptAlias/cgi-bin//usr/lib/cgi-bin/
不允许超限
选项+执行CGI-多视图+符号链接所有者匹配
命令允许,拒绝
通融
ErrorLog${APACHE_LOG_DIR}/error.LOG
#可能的值包括:调试、信息、通知、警告、错误、临界值、,
#警惕,埃默格。
日志级别警告
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
别名/doc/“/usr/share/doc/”
选项索引多视图跟随符号链接
不允许超限
命令拒绝,允许
全盘否定
允许从127.0.0.0/255.0.0.0::1/128开始
请注意,即使该目录中的非Bugzilla静态HTML文件也会受到影响。例如,我在VIM中创建了
/bugzilla/test.html
,然后我尝试在浏览器中访问它,看到它也返回
403/probled
。该目录内外的所有文件都具有相同的用户
ubuntu
和相同的权限
644
bugzilla
目录本身拥有权限
755
,其父目录
public\u html


服务器上没有安装诸如Plesk之类的“控制面板”,所有配置都在Apache配置文件中完成。为什么Apache会决定我可能无权查看
bugzilla
目录?这是在Amazon Web Services托管的公共Web服务器上,在Ubuntu服务器12.04 LTS上。

检查错误日志文件,它通常有非常详细的信息,说明它为什么返回
403禁止的

(它看起来像debian服务器?如果你提出这样的问题,一定要提到操作系统。)

我怀疑这是一个权利问题-错误的所有者。对于debian/ubuntu,给定的文件夹及其文件应由用户“www-data”拥有。对于Centos/Redhat,我认为应该是“无人”。检查,必要时更换

sudo chown -R www-data:www-data test

注意:如果您不确定是否要更改权限,请先复制一份。更改副本的所有者,因为复制本身可能会更改所有者。或者使用rsync制作文件夹的副本,因为rsync保留所有者和权限

你检查过错误日志文件了吗?@TomvanderWoerdt:谢谢!错误日志提到,
.htaccess
本身无法读取。事实上,出于某种原因,它被设置为
640
。我不知道这是怎么发生的,但是
chmod
将它添加到
644
解决了这个问题。谢谢伟大的我会把它添加为答案,这样你就可以这样标记了。谢谢。实际上,在最后我确实提到了它是一个Ubuntu服务器,它本质上就是Debian。原来问题是
。htaccess
没有正确的权限!
sudo chown -R www-data:www-data test