Problem with symlinks

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skarecrow
Forum Newbie
Posts: 4
Joined: Sat Jul 16, 2005 4:35 am

Problem with symlinks

Post by skarecrow »

I am working on a website that creates a temporary directory when a user logs in. When they browse the site, any content they would be accessing should be getting symlinked to that temporary directory so they never know the exact directory the files are in. I am able to create the directory just fine, and create the symlinks as well, but when a user tries to click on the actual content, they get an error... "You don't have permission to access /users/ecc3d1beebc167a61504f4c68db90309/20050511_1_1_8.mpg on this server." I was told this is a very common problem, but I haven't the slightest clue how to resolve it. Can't someone please help me out? I've tried setting the temporary directory AND the actual content directory to 777, and it still gives the same error. I'm running php 4.3.11 and Apache 2.0.54 on kernel 2.4.30-grsec. Thanks in advance for any help.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

I'm guessing the owner of the file is someone other than www. Or it belongs to someone who is not in the right group. That's where I'd start looking. You'll need chown chgrp to make a change in that regaurd.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You need to enable the FollowSymlinks option..

After that you may need to have a look at php configuration (safe mode) too..
skarecrow
Forum Newbie
Posts: 4
Joined: Sat Jul 16, 2005 4:35 am

Post by skarecrow »

I've tried changing the owner AND enabling FollowSymlinks, but neither seems to do anything at all. Maybe I didn't enable FollowSymlinks correctly, can someone post an example?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hopefully not being to patronising but did you restart the web server?
skarecrow
Forum Newbie
Posts: 4
Joined: Sat Jul 16, 2005 4:35 am

Post by skarecrow »

Of course I did, and that didn't fix it. I did figure it out though. I feel like such an idiot, the symlinks were pointing to the wrong place. They were pointing to a directory within the temp directory, which didn't exist, I forgot to .. before going in.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

If you use a shell like bash.. You can enable coloring... Broken symlinks will appear in red ;)

Here's a part from my .bashrc

Code: Select all

# If running interactively, then:
if ї &quote;$PS1&quote; ]; then
        # enable color support of ls and also add handy aliases
        eval `dircolors -b`
        alias ls='ls --color=auto'
        alias dir='ls --color=auto --format=vertical'
        alias vdir='ls --color=auto --format=long'
fi
skarecrow
Forum Newbie
Posts: 4
Joined: Sat Jul 16, 2005 4:35 am

Post by skarecrow »

I'm aware of file/directory coloring. All of the symlinks are showing up as the same color, whether they are broken or valid.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Well, can only advise you to change your configuration ;)

Image
Post Reply