我在运行 OS X 10.10 的办公室 Mac mini 上运行 apache v2.4 来托管个人网站。基本网站运行良好,但当我将符号链接添加到目录(在 ~/anil/Documents/ 文件夹中)时,它会抛出 403 禁止访问错误。
我已经在 /etc/apache2/httpd.conf 上启用了 FollowSymLinks,如下所示
DocumentRoot "/Users/anil/Sites"
<Directory "/Users/anil/Sites">
#
# 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.4/mod/core.html#options
# for more information.
#
Options All MultiViews
MultiviewsMatch Any
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
这是我的 /etc/apache2/users/anil.conf
<Directory "/Users/anil/Sites/">
AddLanguage en .en
LanguagePriority en fr de
ForceLanguagePriority Fallback
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from localhost
Require all granted
</Directory>
我还验证了符号链接目标目录中的所有目录都具有执行权限,但无济于事;为了尝试排除这个问题,我在站点 rootdir 中下一级目录中为虚拟文件创建了一个符号链接,但仍然出现同样的错误。
$ ls -lrt
total 24
-rw-r--r--+ 1 anil staff 49 Feb 24 08:15 somefile
lrwxr-xr-x 1 anil staff 29 Feb 24 09:13 Corpus -> /Users/anil/Documents/Corpus
drwxr-xr-x 3 anil staff 102 Feb 25 07:37 tmp_folder
lrwxr-xr-x 1 anil staff 20 Feb 25 07:38 blankfile -> tmp_folder/blankfile
以下是 apache 的 error_log 的相关输出:
[Thu Feb 25 13:51:14.465824 2016] [core:error] [pid 42861] [client x.x.x.x:p] AH00032: Symbolic link not allowed or link target not accessible: /Users/anil/Sites/blankfile
[Thu Feb 25 13:51:14.465925 2016] [core:error] [pid 42861] [client x.x.x.x:y] AH00037: Symbolic link not allowed or link target not accessible: /Users/anil/Sites/Corpus