Here is my document root at example.com (obviously, an example):
-rw-r--r-- 1 apache apache 366 Apr 25 2016 index.html
lrwxrwxrwx 1 apache apache 38 Oct 13 2015 morestuff -> /media/bigfourterrabytedrive
I have placed a symbolic link (made via ln -s) in the document root directory. The symbolic link points to another directory situated on a device that has massive amounts of storage. The O/S mounts this massive drive automatically via an entry in /etc/fstab
in a
standard Old School fashion so I won't show it.
I write in my favorite browser locator this URL http://example.com/morestuff/
with expectations of success, and not HTTP 403 Access Forbidden
or some such.
First, I need to make sure my Apache server is permitted to follow symbolic links. So I define this for the document root:
<Directory />
Options FollowSymLinks
...
</Directory>
Of course, there are other matters I've defined about the document root, but this is the essential about the symbolic link bit. Most standard httpd.conf files that ship with apache probably have done this for you. Look in your own httpd.conf
to be sure (location varies among distros).
Next, I have to ensure that the user under which the web server process runs is permitted to execute all of the directories in the chain leading to the target directory, viz:
su chmod o+x /media /media/bigfourterrabytedrive
granting execute privileges to world along the entire chain of directories, not just the last one.
Now, since I didn't specify a particular resource when I gave that URL to my browser, the Apache web server assumes I want to look at a directory index. Therefore, to avoid the dreaded 403 on this front, I need to furnish something defaultish to serve up an index. So:
ls -l /media/bigfourterrabytedrive
...
-rw-r--r-- 1 apache apache 366 Nov 20 2016 index.html
...
but, it could also be index.php
or any other file, so long as I've told the web server what kind of files function as indices. So somewhere else in http.conf
<IfModule dir_module>
DirectoryIndex index.html index.php index.aspx
</IfModule>
About the environment: the Apache web server runs as an unprivileged user, apache and any file that I'd like Apache to serve up is usually owned by apache
. There are exceptions:
ls -l /
...
drwxr-xr-x 12 root root 4096 Dec 31 2015 media
...
that is, the directory media
in the chain toward bigfourterrabytedrive
is owned by root, but world execute privileges has been granted on /media
so the unprivileged user apache
can execute /media
whilst on its merry way to bigfourterrabytedrive
Well, I think this is what you need for what ails you, but it is still the wee hours here and I've been known to be mistaken in those hours. Then again, I've been known to be mistaken outside of those hours. Hope this helps.