This question addresses how to enable symbolic links in the Sites directory; however, it only works on directories.
With FollowSymLinks
, Apache on OS X will follow symlinks for directories, but not for files.
For example:
This works: ~/Sites/Experiments -> /Users/myusername/Projects/Experiments/
This fails: ~/Sites/test.html -> /Users/myusername/Projects/Test1/test.html
Forbidden
You don't have permission to access
How can I configure Apache or permissions so that Apache will follow file symlinks?
The target file needs to be readable by the Apache user (probably www-data) for it to be served. Directories are different as most users are able to execute on a directory to view the list of files contained regardless of whether they can read the files contain within.
chmod o+rx /Users/myusername/Projects /Users/myusername/Projects/Test1; chmod o+r /Users/myusername/Projects/Test1/test.html
chmod o+rx /Users/myusername/Projects /Users/myusername/Projects/Test1; chmod o+r /Users/myusername/Projects/Test1/test.html
<Location>
or <Directory>
blocks that are forbidding that target directory from working. <Directory>
block that allows access to your /Users/myusername/Projects/Test1
path. Typically Apache will only grant that access to a default location which doesn't include your home directory. You can do this by temporarily adding in the following (remove it after you've fixed the permissions problem, otherwise it's offering too much access): -
# This is a temporary debugging tool, don't leave it forever.
<Directory "/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
尝试使用chmod
或chgrp
(在最坏的情况下,使用chown
)来设置适当的权限,以至少由Apache Web服务器读取和执行文件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.