0

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?

Handsome Nerd
  • 107
  • 10
  • https://www.git-scm.com/docs/githooks#_post_merge – Michael Hampton Sep 04 '21 at 16:29
  • 2
    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) – Michael Hampton Sep 04 '21 at 16:50

0 Answers0