1

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

MajAfy
  • 107
  • 2
  • 6

1 Answers1

1

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.

Khaled
  • 36,533
  • 8
  • 72
  • 99
  • 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 06 '12 at 08:17
  • @MajAfy You can setup access lists (and probably a default access list) on this folder this using the `setfacl -m u::rwx`, you might want to add the -d and -R options. For more information refer to https://linux.die.net/man/1/setfacl – inaki Jul 03 '18 at 14:37