tags:

views:

2431

answers:

5

Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups...

I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set permissions as such:

chown apache:apache -R uploads/
chmod 755 -R uploads/

The only problem now is that the FTP user can not modify the uploaded files at all.

Is there a permission setting that will allow me to still upload files and then modify them later as a user other than the webserver user?

Thanks!

A: 

It's 777, however it's not the best solution because other people on the web server can also access and modify the files.

Biri
+1  A: 

Or at least 766.

  • read = 4
  • write = 2
  • execute = 1

7 = read + write + execute

6 = read + write

  • first number: owner
  • second number: group
  • third number: other users
Biri
+3  A: 

You can create a new group with both the apache user and FTP user as members and then make the permission on the upload folder 775. This should give both the apache and FTP users the ability to write to the files in the folder but keep everyone else from modifying them.

Ryan Ahearn
A: 

I will add that if you are using SELinux that you need to make sure the type context is tmp_t You can accomplish this by using the chcon utility

chcon -t tmp_t uploads

palehorse
+3  A: 

I would go with Ryan's answer if you really want to do this.

In general on a *nix environment, you always want to err on giving away as little permissions as possible.

9 times out of 10, 755 is the ideal permission for this - as the only user with the ability to modify the files will be the webserver. Change this to 775 with your ftp user in a group if you REALLY need to change this.

Since you're new to php by your own admission, here's a helpful link for improving the security of your upload service: moveuploadedfile

Max