Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
A directory permission without the x bit makes the directory essentially useless. Thus the 764 should really be 775. –  mdpc Apr 20 '13 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. –  Sepahrad Salour Apr 20 '13 at 19:21
    
Okay, I still got this problem even if permissions are set to 777. –  SomeUser Apr 20 '13 at 19:24
    
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 '13 at 19:35
show 1 more comment

3 Answers

Make sure you have apache configured to follow Symbolic Links

Example Config:

<VirtualHost *:80>
    ServerAdmin SomeUser@SuperUser.com

    DocumentRoot /var/www/test
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
<VirtualHost>
share|improve this answer
add comment

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.

share|improve this answer
add comment

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>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.