Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running Fedora Core.

I have a user /home/john/public_html/...

when a php script creates a file, the permissions get set to apache.apache so I cant exit the file through my FTP client without fist logging in a Root and manually changing the permissions to john.

What is the best way to solve this?

share|improve this question
up vote 2 down vote accepted

You can set the permissions on the files to 0666 within your PHP code - but this is not a very neat solution. A more restrictive approach which works for me is to to add the webserver uid and the users requiring access to a common group (e.g. webdev) then setting the group sticky bit on the upload directory and adding files as 0660.

Note that HTTP uploaded files must always be kept in a seperate directory from other web content where PHP (and any other special handler) is disabled (i.e. not in /home/john/public_htm/) otherwise you will get hacked.

...and don't use FTP.


share|improve this answer
Here's how uploading files into public_html can be a security problem: – PleaseStand Dec 1 '10 at 23:32
Please, do not allow uploads to any directory under /home/john/public_html/ (or any directory tree that is mapped into the web server namespace). – Mark Wagner Dec 2 '10 at 0:53

Hm, this is a very common problem. You need to alter your PHP setup so that scripts are executed under the users UID, not apache. There are different tools for this, suexec, suphp (

I've not done any real setup on this before, only done alot of reading about it.

Cheers, good luck.

share|improve this answer

Your Answer


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.