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?

Real Dreams
  • 105
  • 10

0 Answers0