Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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?


share|improve this question
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 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


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


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.