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

When I trying upload file with PHP to a folder that folder should have 777 permission, but this is a security risk, I want set 755 for folder permission but in this permission PHP cannot upload files.

What should I do ?

Server: Linux CentOS

Control Panel : Kloxo

Root Access : Yes

marked as duplicate by Michael Hampton, Magellan, Ward, voretaq7 Dec 7 '12 at 3:12

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.


You can simply change the owner of the upload folder to be apache user using:

$ sudo chown apache_user /path/to/upload/folder

Of course, you need to know the user your web server is running as.

If you want to share the folder between multiple users, you can change the group and grant the group the appropriate permissions.

  • Thank you, this change solved my problem but when I creating a new folder with FTP the owner is user:user so I should change it from SSH again, is there any way to solve this problem for ever ? – MajAfy Dec 6 '12 at 8:17
  • @MajAfy You can setup access lists (and probably a default access list) on this folder this using the setfacl -m u:<uid>:rwx, you might want to add the -d and -R options. For more information refer to linux.die.net/man/1/setfacl – inaki Jul 3 '18 at 14:37

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