This answer is a bit long, but I think the background is important here, so please bear with me.
Reason for the problem
When you're using a symlink, what you're saying is essentially "instead of looking here (/var/www/test), you should look at that directory over there (/home/anotheruser/test)". In order for that to work when serving web files, you need two things:
- the user that apache runs as must be allowed to read that directory - that part you've got correct already with the help from the others
- apache must be configured to allow it to serve files from that directory - and this is the part that's missing.
To take an example: The file /etc/passwd is readable for everyone. Still, you probably don't want it readable for the entire world - so even if you were to make a symlink (ln -s /etc/passwd /var/www/test/passwd
), it still would not be readable unless you specifically tell apache that it's allowed to server files from /etc.
How to fix this
You need to either move the files to a directory that apache is allowed to server pages from, or you need to allow apache to serve pages from the directory where the files live.
Solution 1 - move files
The quickest solution is to turn the symlink around - create the directory /var/www/test
, make anotheruser the owner, and do ln -s /var/www/test /home/anotheruser/
. That way all files are actually stored under /var/www
, so apache is allowed to serve them.
Solution 2 - allow directory
Add a directive to httpd.conf to allow apache to serve content from /home/anotheruser/test
. Then just remove the symlink and set up an alias instead. Like this:
Alias /test /home/anotheruser/test
<Directory /home/anotheruser/test>
Order allow,deny
Allow from all
</Directory>
x
bit makes the directory essentially useless. Thus the 764 should really be 775.id otheruser
id www
ls -lrtd /var/www/test/
ls -lrtd /home/anotheruser/test
. Also, theln -s
command is wrong.