Article 5QN8N Who should be the owner of files in /var/www/ me, as the only user on the server, or www-data?

Who should be the owner of files in /var/www/ me, as the only user on the server, or www-data?

by
Pedroski
from LinuxQuestions.org on (#5QN8N)
Setting up a Ubuntu 20.04 Server on a cloud server.

From this site I am told

Code:sudo mkdir -p /var/www/example.com/public_html
sudo chown -R $USER:$USER /var/www/example.com/public_html
sudo chmod -R 755 /var/www/example.com/public_html
sudo chmod -R 755 /var/www/example.com/public_html
sudo find /var/www/example.com/public_html -type d -exec chmod g+s {} \;Another "set up a virtual server" site told me I should make www-data the owner of all files.

What would you recommend?(I have never had a cloud server before)

At home, on my laptop, I sometimes get "permission denied" error in apache error.log, so then I run the following, which were recommended to me here on LQ:

Code:sudo chown -R pedro /var/www/html
sudo chgrp -R www-data /var/www/html/
sudo chmod -R 770 /var/www/html/
sudo chmod g+s /var/www/html/latest?d=yIl2AUoC8zA latest?i=40MiAIG2qUw:5xRpTSb-LOY:F7zBnMy latest?i=40MiAIG2qUw:5xRpTSb-LOY:V_sGLiP latest?d=qj6IDK7rITs latest?i=40MiAIG2qUw:5xRpTSb-LOY:gIN9vFw40MiAIG2qUw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments