Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

OK. Total beginner question, please bare with me.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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...)

share|improve this answer
    
Thanks, Kyle. What I am mostly 'wondering' about, is if this is an appropriate approach.... –  Adrian Wagner Nov 6 '12 at 7:28
    
It is @AdrianWagner –  Rinzwind Nov 6 '12 at 7:35
    
@AdrianWagner See my updated answer –  Kyle Macey Nov 6 '12 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. –  Adrian Wagner Nov 7 '12 at 2:55
    
useradd (like usermod) is always a bit dangerous -- be careful to use -G and not -g. –  guntbert Oct 26 '13 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
share|improve this answer
    
usermod is always a bit dangerous -- be careful to use -G and not -g. –  guntbert Oct 26 '13 at 11:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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