We have a small LAMP server running Ubuntu 12.04 LTS which contains a few sites. Access to the vhosts directories is set to root:AndSpecialSFTPGroup. This works fine in general. However, some of the sites run on a CMS which need write access to particular folders. This is now not working, because the Apache user is www-data.

Simple question: Is OK to add the www-data to the AndSpecialSFTPGroup group in order to grant it rwx permissions. Or is this the wrong approach altogether.

Or should the owner of the website folders be www-data?

2 Answers 2


There are a few ways you could approach this, but you can add www-data to that group like so:

sudo usermod -a -G AndSpecialSFTPGroup www-data

As far as "Is it the right way to do this?" Like I said, there are many ways to accomplish this, but it's similar to asking me what's the best way to arrange your desk. In many facets of IT, development, and OS, there are choices left up to preference.

This is the way I prefer to handle permissions like this because if I screw something up, I can easily remove the user from the group again. You might like using chown to give all the files to www-data, or something else altogether.

My way is a right way to do this, which is why I most likely won't get flagged for being subjective, but there are other ways. (Like I mentioned chown, create another user, chmod to change the permissions overall, etc...)

  • Thanks, Kyle. What I am mostly 'wondering' about, is if this is an appropriate approach.... Nov 6, 2012 at 7:28
  • It is @AdrianWagner
    – Rinzwind
    Nov 6, 2012 at 7:35
  • @AdrianWagner See my updated answer
    – Kyle Macey
    Nov 6, 2012 at 14:34
  • Thanks again, Kyle. That was the answer I needed. I knew I could solve it this way, but was wondering if there were be no-no's attached to it. Nov 7, 2012 at 2:55
  • useradd (like usermod) is always a bit dangerous -- be careful to use -G and not -g.
    – guntbert
    Oct 26, 2013 at 11:32

This is an old post, but I got to it via Google as the top result for "ubunut add apache to a group".

Since the www-data user already exists the command should be usermod, which is used to modify an existing user.

sudo usermod -a -G AndSpecialSFTPGroup www-data

You can then confirm the change by executing

id www-data
  • usermod is always a bit dangerous -- be careful to use -G and not -g.
    – guntbert
    Oct 26, 2013 at 11:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .