Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have Ubuntu 10.1 installed and I have setup Apache2.

I am going to host about 4-5 websites on this machine, so I need to have a user that controls files/permissions for each website.

I have added a user named 'site1' to control site1.com.

I know I should change the root folder in my apache config to be /home/site1 for site1.com

But the apache server runs on the www-data user, which will not be allowed to perform in actions on /home/site1.

How do I add permissions for www-data to the necessary folders?

Thanks,

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Here is how I would do it. Do the following as root (assuming the site1 user and home directory have already been created):

cd /home/site1
mkdir -m 0770 public_html
chown site1:www-data public_html
chmod g+s public_html

This creates the directory public_html and makes it readable and writable by the www-data group. This should allow Apache to have full access to it. Any files or directories created there will also be owned by the www-data group, because the SGID bit is set on the directory.

Make /home/site1/public_html the root directory of site1.com in your Apache config. I feel it's better to put the web root in a subdirectory of /home/site1, rather than in /home/site1 itself, to keep the site1 user's dotfiles and other potentially sensitive bric-a-brac out of there.

share|improve this answer
    
Thank you very much, that is exactly what I was looking for. –  James D Nov 21 '10 at 16:32

If I am getting this right, you need to change the owner of the

/home/site1

to www-data?

If so, you can execute:

sudo chown -R www-data:www-data /home/site1
share|improve this answer
    
Yes, but I am going to upload files to that directory using the username site1, but the site is running on www-data so basically both users needs permissions to read/write the files on /home/site1 –  James D Nov 21 '10 at 0:13
    
You can add user site1 to www-data group by using the following syntax: useradd -G group_name user_name –  XViD Nov 21 '10 at 0:18

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.