Apache | Symbolic link not allowed or link target not accessible



Recently i needed to add a Symbolic link That Links to a External Directory to my Document Root, avoid copying work files from the external storage to the Document Root.

So i made the link using (ln -s) and configured the apache2.conf settings to allow Symbolic Links and restarted Apache with all configurations OK, bur when i browse the local server on 127.0.0.1, i cant see the linked server and when i try to access it ( 127.0.0.1/target/ ) it gives a Permission Problem?

After a long search i found out that all the configurations is Correct and the problem is pure Permission Problem after looking into the log file it says "Symbolic link not allowed or link target not accessible".

The Problem: Apache needs Permission to not only the folder in which is linked, instead it needs permission to all the way through until reaching it, so for example if you have your linked folder source in (USB/WORKS/PROJECTS/PROJECT_01), you need to set the permission of all these folders so that the user that runs Apache (for example [www-data]) have at least access permission...

The Solution:
1- Create a Symlink for your folder ( /home/user/workspace ) for example to /var/www/html
example: sudo ln -s /home/user/workspace /var/www/html/ws

2- Add Apache user to your user group
sudo usermod -a -G usergroup www-data
 
3- Restart apache
sudo service apache2 restart
 
now you can open the url from your browser, http://localhost/ws

THEN
sudo chmod 755 /media/USB1

DONE! Now you can reload your apache server and you can access all the files.... ENJOY 😀

Comments