4

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?

Community
  • 1
  • 1

3 Answers3

1

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.

mrverrall
  • 121
  • 2
1
  1. Check that the file permission on the target file and all of it's parent directories are accessible by your webserver user (probably www-data). World-readable permission is good enough. If you don't care about security all that terribly much (meaning that this isn't a production system), you can just do something like this: chmod o+rx /Users/myusername/Projects /Users/myusername/Projects/Test1; chmod o+r /Users/myusername/Projects/Test1/test.html
  2. Be sure that you don't have any <Location> or <Directory> blocks that are forbidding that target directory from working.
  3. Be sure that you do have a <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>
Emmaly
  • 863
  • 7
  • 22
0

Try using chmod or chgrp (in worst-case scenario, chown) to set appropriate permissions to at least read and execute the files by Apache web server.

Vishal
  • 2,161
  • 14
  • 25