1

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.

2
  • can you run ls -lha in /home/fred/someFolder and post it up here? Commented Feb 14, 2011 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 ../ Commented Feb 14, 2011 at 18:00

2 Answers 2

0

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

4
  • I have done that and still receive the same error. Commented Feb 14, 2011 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. Commented Feb 14, 2011 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! Commented Feb 14, 2011 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. Commented Feb 14, 2011 at 18:47
0

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!

1
  • getenforce seems to already be disabled. Commented Feb 14, 2011 at 18:18

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.