# How to make new files automatically belong to group?

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

chmoding a directory setgid (g+s) will make all files created within it inherit group ownership.
• 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