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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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