Score:0

File permissions and owner of web root

in flag

Consider you have a freshly installed Linux distro (maybe a new EC2 instance) and you are going to run a git clone on the /srv folder to host a website (maybe a PHP one).

How should you run the git clone so every created files and folder have the correct permission/groups? You are going to use an HTTP Server similar to Nginx to serve the website.

In this post the author has suggested this:

# 0. settings
web_dir=/srv/www
myusername=kassambara
# 1. Create the website directory
sudo mkdir -p $web_dir
# 2. set your user as the owner
sudo chown -R $myusername $web_dir
# 3. set the web server as the group owner
sudo chgrp -R www-data $web_dir
# 4. 755 permissions for everything
sudo chmod -R 755 $web_dir
# 5. New files and folders inherit 
# group ownership from the parent folder
chmod g+s $web_dir

Is this the best practice?

Michael Hampton avatar
cz flag
https://www.git-scm.com/docs/githooks#_post_merge
Michael Hampton avatar
cz flag
Does this answer your question? [What permissions should my website files/folders have on a Linux webserver?](https://serverfault.com/questions/357108/what-permissions-should-my-website-files-folders-have-on-a-linux-webserver)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.