Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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

share|improve this question

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

This question was marked as an exact duplicate of an existing 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.

share|improve this answer
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

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