【问题标题】:Forbidden: You don't have permission to access / on this server禁止:您无权访问此服务器上的 /
【发布时间】:2016-10-03 19:47:02
【问题描述】:

我一直有这个access denied 错误。我在 CentOs 6.4 上使用 apache 2.2.15 服务器与用户 apache 和组 apache 一起运行。 在家里,我有一个用户staging。我将他添加到 apache 组

docs 文件夹的权限是:

drwxrwx--- 2 staging staging 4096 Oct  4 14:33 docs

我正在使用 index.html 文件进行测试:

-rw-r--r-- 1 staging staging   13 Oct  4 14:28 index.html

SELinux 已禁用。我使用的地址是 staging.mysite.com

我的httpd.conf 看起来像这样:

<Directory "/home/*/docs">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
# 
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
# 
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options FollowSymLinks

# 
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

# 
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>

我还为我的暂存地址设置了一个虚拟主机:

<VirtualHost SERVERIP:80>
        ServerName staging.mysite.com
        DocumentRoot /home/staging/docs
        ServerAdmin staging@mysite.com
        CustomLog /home/staging/logs/access_log combined
</VirtualHost>

如果您需要更多信息,请告诉我,但知道为什么会出现此错误吗?

【问题讨论】:

    标签: apache


    【解决方案1】:

    好吧,正如您所说,docs 文件夹只能由登台用户和登台组读取。所以apache用户可能看不懂。

    一种解决方案是将 apache 用户添加到暂存组。

    【讨论】:

    • apache 用户是 apache 组的一部分,我像我说的那样将 staging 用户添加到了 apache 组。
    • 我读到了,但是 apache 组没有对 docs 文件夹的读取权限。
    • 我将 /home/staging/docs 组及其内容更改为 apache,但它什么也没做...
    • @user2847120 那么 /、/home/ 和 /home/staging/ 呢?在 Unix 中,为了被允许访问文件,您需要对所有父目录具有读取权限。
    • 知道了。除了文件夹暂存之外,其他地方的权限都可以。一个 chmod 751 做到了。谢谢!
    【解决方案2】:

    我可以修复同样的错误:

    要在您的 nagios 配置中修改选项参数 +Indexes 并添加 DirectoryIndex index.php

    可能是:

    <Directory "/home/*/docs">
    
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    # 
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    # 
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
        Options FollowSymLinks +Indexes
    
        DirectoryIndex index.php
    
    # 
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
        AllowOverride All
    
    # 
    # Controls who can get stuff from this server.
    #
        Order allow,deny
        Allow from all
    
    </Directory>
    

    最后重新启动你的 apache 服务。

    检查/home/的权限可以是+x和+r,比如chmod +rx /home/

    【讨论】:

    • '' 语法在 Apache 2.2.15 中不受支持
    猜你喜欢
    • 2019-09-11
    • 2014-06-07
    • 2018-08-06
    • 2013-05-15
    • 2016-05-06
    • 2017-08-10
    • 2014-02-28
    • 2020-04-16
    相关资源
    最近更新 更多