Nginx Virtual Host Directory Permissions

May 7, 2014 9.4k views
I have been attempting to set proper permissions during the configuration of a virtual host but keep running into a 404 page error. It only occurs during permission changes. What is the best directory permission for multiple virtual hosts? /var/www/vhosts/website1/httpdocs /var/www/vhosts/website2/httpdocs Currently, I am copying the default skeleton directory and then using useradd to set the home directory to those identified above and then adding each user to the www-data group. Once I do this, even changing ownership to the user:www-data and permissions as 0770 I start seeing the 404 page. Any good guides that explain permissions for web root directories?
1 Answer
Disregard. Finally figured it out.

# Add user with a pre-determined home directory
sudo useradd -s /bin/false -d /var/www/vhosts/website1 -m user1

# Add the user to the www-data group
sudo usermod -aG www-data user1

# Change password
sudo passwd user1

# Change the owner of website1 to the user and www-data
sudo chown -R user1:www-data /var/www/vhosts/website1

# Change permissions owner = all, group = all, anyone = r+x
sudo chmod -R 0775 /var/www/vhosts/website1

# Make all changes below this directory inherit same permissions
sudo chmod g+s /var/www/vhosts/website1

This is what I have so far. Open to suggestions.
Have another answer? Share your knowledge.