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 used chgrp for the 'logs' and 'cache' directories, and chmod 770, so both the linux user asigned to that site (used to execute scripts from the command-line), and the user 'apache' can read/write log and cache files (because both users belong to the group of that site).

The problem is that when one of them creates a file, the other one is not able to write or delete it. The file is being created as owned by its creator, but not belonging to the group. I thought using chgrp in the parent directory was the solution.

Any ideas?

PS: I'm on Centos 5.5, and PHP 5.3

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

chmoding a directory setgid (g+s) will make all files created within it inherit group ownership.

share|improve this answer
1  
+1, You will may also want to adjust the umask of the users, or services writing into that folder so group members have write access. –  Zoredache Mar 10 '11 at 1:35
    
It worked, thanks. But is there a way to make all the dirs and files created have 770 permission? My scripts creates both dirs and files –  HappyDeveloper Mar 10 '11 at 2:09
    
Permissions are related to the umask of the creating process. –  Ignacio Vazquez-Abrams Mar 10 '11 at 2:10
    
You can also do this, albeit less portably, using POSIX ACLs. I'm fuzzy on the specifics since I rarely use them, but you can man setfacl for details. –  jgoldschrafe Mar 10 '11 at 3:11
add comment

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.