使用 Apache 修复别名目录上的 403 Forbidden [英] Fixing 403 Forbidden on alias directory with Apache

查看:45
本文介绍了使用 Apache 修复别名目录上的 403 Forbidden的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个别名以指向我的文件系统上的某个目录,而不是在 DocumentRoot 中.现在我收到 403 Forbidden 响应.这些是采取的步骤:1.编辑http.conf,添加:

I am trying to setup an alias to point to some directory on my filesystem not in DocumentRoot. Now I get a 403 Forbidden response. These are the steps taken: 1. edit http.conf, adding:

Alias /example "/Users/user/Documents/example"

然后...

<Directory "/Users/user/Documents/example">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride None
   Order allow,deny
   Allow from all</Directory>

2.在终端中使用 chmod 设置权限:

2. setting permissions with chmod in terminal:

chmod 755 /Users/user/Documents/example

现在应该可以了吗?相反,我禁止访问.这是 error_log 的输出:

Now it should work? instead I get the access forbidden. This is the output from error_log:

[Sun Jul 24 06:57:57 2011] [error] [client xx.xx.xx.xx] (13)Permission denied: access to /example denied

推荐答案

我在 OS X 上也遇到了这个问题.结果证明 gliptak 是正确的,但我还有更多细节要补充.

I was having this issue on OS X too. It turned out gliptak was right, but I've some more detail to add.

我们都在尝试为用户主文件夹下的文件夹配置虚拟目录;我认为这就是我们遇到问题的原因.就我而言,我进行了以下设置:

We're both attempting to configure a virtual directory for a folder under a user's home folder; I think this is why we're having the problem. In my case, I had the following setup:

  • 主文件夹是 /Users/calrion.
  • 虚拟目录文件夹是/Users/calrion/Path/to/www.
  • 有一个符号链接 /Users/calrion/Path 指向 /Volumes/Other/Users/calrion/Path.
  • Home folder is /Users/calrion.
  • Virtual directory folder is /Users/calrion/Path/to/www.
  • There's a symlink /Users/calrion/Path pointing to /Volumes/Other/Users/calrion/Path.

问题是用户和组 _www(Apache 在 OS X 上运行)缺乏对 /Users/calrion/Volumes/Other 的执行访问/Users/calrion.

The problem was the user and group _www (which Apache runs as on OS X) lacked execute access to /Users/calrion and /Volumes/Other/Users/calrion.

运行 chmod o+x/Users/calrionchmod o+x/Volumes/Other/Users/calrion 解决了问题(在 OS X 10.7.4 上).

Running chmod o+x /Users/calrion and chmod o+x /Volumes/Other/Users/calrion resolved the issue (on OS X 10.7.4).

这里的规则是 Apache 需要对路径中的所有文件夹的执行访问权限才能提供文件.如果没有这个,你会得到一个 HTTP 403(禁止).

The rule here is that Apache requires execute access to all folders in the path in order to serve files. Without this, you'll get a HTTP 403 (forbidden).

这篇关于使用 Apache 修复别名目录上的 403 Forbidden的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆