Apache files as not www-data

There used to be a pretty cool mod for apache that allowed it to run certain vhosts as someone other than www-data.

Unfortunately this mod has not been kept up to date and doesn’t work reliably on newer versions of Apache2. As such you are left with a dilema, either act as apache or add apache and yourself to a group who has rights to the files.

For a dev server the better option IMO is to allow devs to ssh in as apache and thus nothing else is required. Each dev can sync their files and everything just works nicely. The reason for this is the usual suspect, Windows. Although there is Cygwin which gives linux toolbox to Windows users, there is still no way around syncing between Linux and Windows and the permissions being correct. Windows and *nix file systems are just fundamentally different. Don’t believe me, try it out for yourself, either:

  1. Rsync a fileset from a linux server to a windows desktop. Now try work on them or sync them back or even try commit the changes to git.. no joy.
  2. Rsync a  fileset from a windows desktop to a linux server.. it is basically not possible yet to retain all the file permissions. Doesn’t matter which flags you add.

Back to the topic

NB: To see users and groups see this post: previous post

Create a new usergroup webdev and add the www-data user to it and then any other users you need in this group.

At this point you have a group apache and you can both write within it. Now in the folder with the files you want to work on and apache to server you need to apply a default group:

Next we can verify:

Output:

Last thing to do is to make sure, the group webdev has rwx rights on the files

Leave a Reply

Your email address will not be published. Required fields are marked *