1

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,

James D
  • 13
  • 2

2 Answers2

1

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.

Steven Monday
  • 13,599
  • 4
  • 36
  • 45
0

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
XViD
  • 46
  • 2
  • 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 00: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 00:18