Right file owner/group for files created by apache and required to be editable by local user

Code Poet asked:

I am running apache on a MacOSX Lion machine. I’ve got this site (Joomla 1.5) that creates files in the cache directory or it’s subdirectories. There are instances when the subdirectories are also created by apache.

When files and directories are created by apache, they end up with the group:user set to _www:_www (apache user on mac).

Problem is, I often want to delete these files while I’m logged in with my credentials (say code_poet). I’m not part of the _www group, so obviously, I cannot delete these files as these files typically have rwxr_xr_x set.

My question, therefore is how best to get around this problem, without adding myself to the _www group (I’m not even sure if I could add myself to that group). A workaround obviously is to use sudo, but that doesn’t work if I’m trying to do a delete via a UI tool like SmartGit.

PS: I’m not too familiar with these unix like permission concepts but I read something about mask bit and tried to set the cache folder perms to u+rws while having the cache folder perms owner:group set to code_poet:www, but it does not achieve the desired result.

If I understood correctly, files/directories created under this folder should inherit the owner id from the parent.

My answer:

Make the files owned by your user account, and group owned by apache. Then make them group writable, so that both you and apache can write to them.

chown -R user._www /path/to/cache
chmod -R ug+w,o-w /path/to/cache

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.