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.

Possible Duplicate:
What are the best linux permissions to use for my website?

What is the correct way to set up directories to allow user uploads on Linux? My websites upload dir is 755, but Linux naturally doesn't let files be written to this directory except by the user. So should I change the directory to 777 or do some kind of group manipulation? Bare in mind, I don't want to open myself up to any security risks.

share|improve this question

marked as duplicate by Michael Hampton, Tom O'Connor, mulaz, rnxrx, Ward Oct 6 '12 at 20:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers 3

up vote 0 down vote accepted

if you let 777 will be risky for your server, better to create a folder pertinent owner and group permittions (like 775) and from y our application use the owner, so, you wont put yourself in risk.

share|improve this answer
    
"from y our application use the owner". How would I do this in PHP? And wouldn't that be just as risky as someone could use my app code to inject their own? –  John Bowlinger Sep 14 '12 at 22:38
    
will be as risky as not secure will be your application, but will eliminate all the risks of the 777 on a directory, that will let people put things there even if is not through your app. Use the apache user for give permittion to your folder stackoverflow.com/questions/4378592/… –  jpganz18 Sep 17 '12 at 14:09

What about using ACLs on the selected directory area permitting the user R/W?

share|improve this answer
    
Now I have to go read about ACL's and how to implement them in PHP. There goes my weekend. –  John Bowlinger Sep 14 '12 at 22:42

bindfs could help you. It is a FUSE filesystem which allows bind-mounting directories and altering and enforcing different permissions inside the mount point. If ACLs are too difficult for you to implement correctly, bindfs could be a solution. Beware of noticeable performance impact, though.

share|improve this answer

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