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.

I have created an SSH user on our system, fred, whose home directory is /home/fred and who has a subdirectory at /home/fred/someFolder. I am trying to allow PHP/Apache, which is running as nobody, to be able to create a file inside fred's someFolder directory. No matter what I try, I always get Warning: file_put_contents(/home/fred/someFolder/test.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/websiteDir/public_html/test.php on line 1

I have tried several different ways of doing this and nothing seems to work so far. Tried to chmod the folder to 777, 666, 660, etc. Tried chown with fred:nobody, nobody:fred, nobody:nobody, fred:fred, still nothing. Tried adding fred to nobody's group, tried adding nobody to fred's group, nada.

Sorry, I'm not all that great at linux... any advice would be appreciated.

share|improve this question
    
can you run ls -lha in /home/fred/someFolder and post it up here? –  gravyface Feb 14 '11 at 17:52
    
total 8.0K drw-rw---- 2 nobody fred 4.0K Feb 14 11:15 ./ drwx--x--x 5 fred fred 4.0K Feb 14 11:15 ../ –  Jamin Feb 14 '11 at 18:00

2 Answers 2

up vote 0 down vote accepted

All parent directories of /home/fred/someFolder must have the execute bit set for the user/group accessing it. So most likely /home/fred is missing this. chmod a+x /home/fred

share|improve this answer
    
I have done that and still receive the same error. –  Jamin Feb 14 '11 at 18:16
    
From looking at your comment on gravyface's question, youre missing the execute bit on 'someFolder'. All folders must have the execute bit set, or theyre pretty much useless. –  Patrick Feb 14 '11 at 18:20
    
Ah, that finally did it. When you said 'parent directories' I wasn't thinking about the actual one I needed, only the ones above it. Thank you so much! –  Jamin Feb 14 '11 at 18:23
    
Thats ok, I didnt expect the execute bit to be missing from it as it should be there by default on all newely created directories. –  Patrick Feb 14 '11 at 18:47

Check whether SELinux is running in Enforcing mode. If so, it can cause permissions issues that don't appear to be supported by the actual UNIX file permissions you're seeing and setting. You can use getenforce (at least on Redhat/CentOS) to see the state of SELinux, and setenforce 0 to disable it interactively. In order to have the change persist, you'll need to edit the SELinux configuration in /etc/selinux/config. Hope that helps!

share|improve this answer
    
getenforce seems to already be disabled. –  Jamin Feb 14 '11 at 18:18

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.