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 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

2 Answers 2

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.

C.

share|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

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.

share|improve this answer

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.