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?

link|improve this question

50% accept rate
feedback

2 Answers

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 (http://www.suphp.org/Home.html).

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

Cheers, good luck.

link|improve this answer
feedback

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.

C.

link|improve this answer
Here's how uploading files into public_html can be a security problem: scanit.be/uploads/php-file-upload.pdf – 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
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.