0

I made symlink when logged in as www (apache user):

ln -s /home/anotheruser/test /var/www/test

Now I go to my mydomain.com/test and I get a 403 error.

/home/anotheruser/ has permissions 764 (group read + write and public read) otheruser and www are in the same group.

So, what permissions do I have to give to the /home/anotheruser folder to make this work?

6
  • A directory permission without the x bit makes the directory essentially useless. Thus the 764 should really be 775.
    – mdpc
    Apr 20, 2013 at 19:21
  • For first time change permissions of all of file and directory you working with to 777, To determine that Where we have problem. Apr 20, 2013 at 19:21
  • Okay, I still got this problem even if permissions are set to 777.
    – SomeUser
    Apr 20, 2013 at 19:24
  • @SepahradSalour serverfault.com/questions/364677/why-is-chmod-r-777-destructive
    – dawud
    Apr 20, 2013 at 19:29
  • 1
    The question is not clear at all. Please reproduce exactly the commands you executed, and please show us: id otheruser id www ls -lrtd /var/www/test/ ls -lrtd /home/anotheruser/test. Also, the ln -s command is wrong.
    – dawud
    Apr 20, 2013 at 19:35

3 Answers 3

1

Make sure you have apache configured to follow Symbolic Links

Example Config:

<VirtualHost *:80>
    ServerAdmin [email protected]

    DocumentRoot /var/www/test
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
<VirtualHost>
0

This HTTP error may not be file system related per se, you can either chose to list all filesusually:

   <VirtualHost *:80>
     ...
     <Directory>
       Options +Indexes
     </Directory>   
     ...
   </VirtualHost>

Would do the trick, else you can try to access a file directly from that directory, if there's no security settings such as chroot or so.

0

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>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .