【问题标题】:Don't Have Permission To Access / On This Server无权访问/在此服务器上
【发布时间】:2013-02-24 19:36:31
【问题描述】:

我已经查看了许多关于 SO 的类似问题,例如 this one,我什至可以通过在全局目录中进行更改来解决我的问题。但是,我想在 httpd-vhosts.conf 文件中进行更改。这是我目前拥有的:

<VirtualHost *:80>
    ServerAdmin someEmail@gmail.com
    DocumentRoot "c:/www/firstSite.dev"
    <Directory "c:/www/firstSite.dev/">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order deny,allow
        Allow from all
    </Directory>
    ServerName firstSite.dev    
</VirtualHost>

但是,我仍然收到错误:

禁止

您无权访问此服务器上的 /。

任何帮助将不胜感激。

【问题讨论】:

  • 你有 .htaccess 吗?您使用的路径需要管理员权限才能更改任何文件。这条路的尽头是什么?
  • 我没有 .htaccess 文件。所有用户都可以完全访问 C:/www/。这也是整个路径(即 c:/www/firstSite.dev/index.html)

标签: windows apache virtualhost


【解决方案1】:

您需要在 httpd.conf 文件中明确添加您的用户。以下行将执行trick

User daemon
Group daemon
User *user here*

【讨论】:

    【解决方案2】:

    如果您碰巧使用的是包含 SELinux(例如 CentOS)的 linux 发行版,您需要确保为您的文档根文件正确设置了 SELinux 权限,否则您将收到此错误。在 RedHat / CentOS / Scientific Linux 上,这可以通过编辑 /etc/sysconfig/selinux 来完成 - 找到参数“selinux”并将选项“enforcing”更改为“disabled”:

    # SELINUX= can take one of these three values:
    #       enforcing - SELinux security policy is enforced.
    #       permissive - SELinux prints warnings instead of enforcing.
    #       disabled - No SELinux policy is loaded.
    SELINUX=disabled
    

    然后重新启动服务器并进行测试。如果解决了问题,您可以禁用 SELinux,或配置 SELinux 以便您可以访问您的站点。这里有一个很好的 SELinux 配置教程:http://beginlinux.com/server_training/web-server/976-apache-and-selinux

    【讨论】:

      猜你喜欢
      • 2013-06-30
      • 2019-02-22
      • 2017-10-31
      • 2017-05-04
      • 2015-10-06
      • 2015-10-07
      • 2012-12-08
      相关资源
      最近更新 更多