Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For example, I'm having the same problem as in this question: Apache won't follow symlinks (403 Forbidden)

My DocumentRoot is located at /srv/http/default/htdocs and I'm trying to symlink it to /home/trusktr/htdocs.

To get it to work, I had to chmod o+x every directory down to /home/trusktr/htdocs, so for example:

chmod o+x /home
chmod o+x /home/trusktr
chmod o+x /home/trusktr/htdocs

and then it started working just like in the question I mentioned above.

I have Options Indexes FollowSymLinks set for /srv/http/default/htdocs.

How do I make symlinks (softlinks) work without having to chmod any folders to o+x?

share|improve this question

migrated from stackoverflow.com Oct 8 '12 at 12:05

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

That obviously depends on the ownership (group) of the folders.

You only need to set the global execution for the folders if the apache process does not have access to the folders. If you want to prevent giving global execution rights then reassign the folders to the group the apache process runs as and give execution rights to that group ("g+w").

share|improve this answer
add comment

Think like apache - wherever link points to, the user apache runs on ( or probably the one assigned for virtualhost if you use FastCGI) has to have filesystem access to this destination. You can "fix" it in a few ways:

1) like you described, chmodding directories

2) you add add user to the same group as apache and make directories group readable

3) instead of chmodding it for apache you can do opposite direction - link it for the user, and put in physically under apache's htdocs tree ( or add apache user to some group user belongs to, and make his directory group readable )

4) you can use "mount -bind" to mount destination into some directory visible by apache. There's a way to use suexec to do it dynamically, however if it's specific case and one directory, you could just mount it by hand I guess ( possibly put mount -bind into fstab if needed )

Anyway, like arkascha said, it's permission problem, mostly solved by manipulating group ownership/group readable right.

Oh, and when you need to CHECK if it works, I mean if apache sees what it's supposed to see, you can make sure it does with sudo-ing to apache user ( from the root session, like "su -s /bin/bash www-data" ) - and while being apache user, try simply "cd" to that directory. So if this user will be able to go to specific directory, webserver which works as "him" will be able too.

6) Theoretically, you could also configure apache to run as the same user you need to access directory to (instead of www-data or so), but this will probably be the worst idea of them all :)

share|improve this answer
    
Hi Piotr, for suggestion #2, do you mean "add user to the same group as apache" or "add apache to the same group as user" then g+x the folder, or g+x all parents of the folder also? For suggestion #3 do you mean "add apache user to any group user belongs to" then g+x the folder or all directories down to the folder? –  trusktr Oct 8 '12 at 7:00
    
I tried the mount --bind suggestion but that still doesn't work because the permissions with the files still block Apache. Everyting is readable (o+r) but apache still doesn't get access. –  trusktr Oct 8 '12 at 7:11
1  
I got it working. I think the best solution is to make the folder I'm symlinking to or mounting owned by the apache user's group. –  trusktr Oct 8 '12 at 7:41
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.