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.

I have a php script which uploads images to a folder.

I have these permissions on the upload folder:

  drwxrwxr--  4 user user   4096 2010-06-02 16:20 temp_images

Shouldn't these permissions be enough for files to be uploaded to the folder?

But this doesn't work.

It only works when I set the permissions to 777.

"user" is added to the www-data group, still no luck.

Any ideas why?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Your folder is owned by the user and group user. If apache is running as a different account, perhaps www-data then apache will not be able to write there. Adding the user account to the www-data group would mean that user is permitted to write in folders that the www-data group owns and is set for rw. If you want apache to write to the folder the group user owns the apache service account must be a member of the user group.

share|improve this answer

If safe_mode is on, then user should be the apache/php user unless you set safe_mode_gid to on where check is done on group instead of user

share|improve this answer
    
what do you mean? if safe_mode is off, then apache user doesn't matter? –  Anonymous12345 Jun 2 '10 at 15:23
    
see Zoredache answer, I miss readed something in your question –  radius Jun 2 '10 at 18:09

The owner of the directory should be the effective userid of the web servers. Try changing the ownership, then you can set the permissions to 700, 750, or 755.

chown www-data temp_images

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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