M BUZZ CRAZE NEWS
// general

How to use a symlink in Apache Web Server

By Sarah Rodriguez

I Installed Apache2. In the the folder "var/www/html" I created a symlink to a different HDD that holds a number of movie files. My thinking is that it would be easy to access the movies through a browser from any computer on my local network.

I used the following command string while in the html directory, and created the symlink:

ln -sd /media/guy/movie1/Movies test

While sitting at the server if I click on "test" it opens the correct directory and exposes the files. If I surf to apache from another machine it does not show the symlink.

Excerpt from Apache access log:

192.168.1.158 - - [12/May/2015:08:40:07 -0400] "GET /favicon.ico HTTP/1.1" 404 502 "-" "Mozilla/5.0 (X11; Linux i686; rv:24.7) Gecko/20140802 Firefox/24.7 PaleMoon/24.7.1"
192.168.1.158 - - [12/May/2015:08:40:07 -0400] "GET /favicon.ico HTTP/1.1" 404 502 "-" "Mozilla/5.0 (X11; Linux i686; rv:24.7) Gecko/20140802 Firefox/24.7 PaleMoon/24.7.1"
192.168.1.158 - - [12/May/2015:08:40:07 -0400] "GET /favicon.ico HTTP/1.1" 404 502 "-" "Mozilla/5.0 (X11; Linux i686; rv:24.7) Gecko/20140802 Firefox/24.7 PaleMoon/24.7.1"
192.168.1.158 - - [12/May/2015:08:50:38 -0400] "GET / HTTP/1.1" 200 584 "-" "Mozilla/5.0 (X11; Linux i686; rv:24.7) Gecko/20140802 Firefox/24.7 PaleMoon/24.7.1"
192.168.1.158 - - [12/May/2015:08:50:39 -0400] "GET /icons/blank.gif HTTP/1.1" 304 178 "" "Mozilla/5.0 (X11; Linux i686; rv:24.7) Gecko/20140802 Firefox/24.7 PaleMoon/24.7.1"
3

1 Answer

A symlink should work fine. You may or may not need to add the directory to /etc/apache2/apache2.conf so that apache knows it is allowed to access the non-standard directory.

Example (note: I do not use the -d option):

doug@s15:/var/www/html$ ln -s /media/newhd/test_web bla2
doug@s15:/var/www/html$ ls -l
total 44
...
lrwxrwxrwx 1 doug doug 21 May 11 22:14 bla2 -> /media/newhd/test_web
...

Excerpt from '/etc/apache2/acpahe2.conf'

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted
</Directory>
<Directory /media/newhd/test_web/> Options Indexes FollowSymLinks AllowOverride None Require all granted
</Directory>

Make sure all permissions, including parents, are in order. You can do it manually, directory by directory or:

$ namei -m /media/newhd/test_web
f: /media/newhd/test_web drwxr-xr-x / drwsrwsrwt media drwxr-xr-x newhd drwxr-xr-x test_web

Now, there are some files systems that do not work with Apache, my example was an ext4 filesystem. And some disks that are automounted (mine is not) need an fstab entry to work properly.

Otherwise help us to help you with a little more information, such as any /var/log/apache2/*.log entries.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy