What is the correct linux owner and linux group for /var/www?

I was tinkering around with the Linux owners (chown) and Linux groups (chgrp) for the directory path /var/www and I lost track of what it was supposed to be :grimacing: now I am wondering what it should be.

Can anyone run these commands and tell me what their outputs are so I can put it back in place?

ls -l / | grep var
drwxr-xr-x  14 root mumble-server  4096 Jun 30 10:01 var
ls -l /var | grep www
drwxrwx---  5 root mumble-server 4096 Jul  4 00:57 www
ls -l /var/www
total 16
drwxrwx--- 2 root mumble-server 4096 Feb 27  2019 html
drwxrwx--- 2 root mumble-server 4096 Jul  4 06:23 mumbleserver
-rwxrwx--- 1 root mumble-server 6859 Jun 30 11:04 mumble-server.ini

Currently every app I install has the same problem, failing whenever it runs sudo -u <username>, e.g.

sudo -u peertube _______
sudo -u etherpad _______

Failure logs

Here are failure logs. I notice it seems to fail whenever it tries to use a new user it created, which I believe means I messed up my Linux owner and Linux group for the /var/www path.

peertube

2020-07-03 09:46:48,242: DEBUG - ++ ynh_app_setting get peertube nodejs_version
2020-07-03 09:46:48,245: DEBUG - ++ [[ get == \d\e\l\e\t\e ]]
2020-07-03 09:46:48,247: DEBUG - ++ ACTION=get
2020-07-03 09:46:48,249: DEBUG - ++ APP=peertube
2020-07-03 09:46:48,252: DEBUG - ++ KEY=nodejs_version
2020-07-03 09:46:48,254: DEBUG - ++ VALUE=
2020-07-03 09:46:48,257: DEBUG - ++ python2.7 -
2020-07-03 09:46:49,112: DEBUG - ++ [[ nodejs_version =~ ^(unprotected|skipped)_ ]]
2020-07-03 09:46:49,114: DEBUG - + nodejs_version=10
2020-07-03 09:46:49,117: DEBUG - + nodejs_path=/opt/node_n/n/versions/node/10/bin
2020-07-03 09:46:49,119: DEBUG - + shopt -s expand_aliases
2020-07-03 09:46:49,122: DEBUG - + ynh_node=/opt/node_n/n/versions/node/10/bin/node
2020-07-03 09:46:49,126: DEBUG - + alias ynh_node=/opt/node_n/n/versions/node/10/bin/node
2020-07-03 09:46:49,129: DEBUG - + ynh_npm=/opt/node_n/n/versions/node/10/bin/npm
2020-07-03 09:46:49,131: DEBUG - + alias ynh_npm=/opt/node_n/n/versions/node/10/bin/npm
2020-07-03 09:46:49,134: DEBUG - + [[ :/opt/node_n/n/versions/node/10/bin:/opt/node_n/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: != *\:\/\o\p\t\/\n\o\d\e\_\n\/\n\/\v\e\r\s\i\o\n\s\/\n\o\d\e\/\1\0\/\b\i\n* ]]
2020-07-03 09:46:49,137: DEBUG - + node_PATH=/opt/node_n/n/versions/node/10/bin:/opt/node_n/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2020-07-03 09:46:49,139: DEBUG - + ynh_node_load_PATH=PATH=/opt/node_n/n/versions/node/10/bin:/opt/node_n/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2020-07-03 09:46:49,142: DEBUG - + sudo -u peertube env PATH=/opt/node_n/n/versions/node/10/bin:/opt/node_n/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin yarn install --production --pure-lockfile
2020-07-03 09:46:54,810: WARNING - Error: EACCES: permission denied, open '/var/www/.yarnrc'
2020-07-03 09:46:54,816: WARNING -     at Object.openSync (fs.js:443:3)
2020-07-03 09:46:54,822: WARNING -     at readFileSync (fs.js:343:35)
2020-07-03 09:46:54,830: WARNING -     at /usr/share/yarn/lib/cli.js:101331:58
2020-07-03 09:46:54,837: WARNING -     at Array.map (<anonymous>)
2020-07-03 09:46:54,842: WARNING -     at parseRcPaths (/usr/share/yarn/lib/cli.js:101329:78)
2020-07-03 09:46:54,847: WARNING -     at Object.findRc (/usr/share/yarn/lib/cli.js:101343:10)
2020-07-03 09:46:54,854: WARNING -     at getRcConfigForCwd (/usr/share/yarn/lib/cli.js:56915:74)
2020-07-03 09:46:54,861: WARNING -     at /usr/share/yarn/lib/cli.js:92694:56
2020-07-03 09:46:54,867: WARNING -     at Generator.next (<anonymous>)
2020-07-03 09:46:54,872: WARNING -     at step (/usr/share/yarn/lib/cli.js:310:30)
2020-07-03 09:46:54,978: DEBUG - + ynh_exit_properly
2020-07-03 09:46:54,980: DEBUG - + local exit_code=1
2020-07-03 09:46:54,982: DEBUG - + '[' 1 -eq 0 ']'
2020-07-03 09:46:54,984: DEBUG - + trap '' EXIT
2020-07-03 09:46:54,985: DEBUG - + set +o errexit
2020-07-03 09:46:54,987: DEBUG - + set +o nounset
2020-07-03 09:46:54,989: DEBUG - + sleep 0.5
2020-07-03 09:46:55,494: DEBUG - + type -t ynh_clean_setup
2020-07-03 09:46:55,496: DEBUG - + ynh_clean_setup
2020-07-03 09:46:55,498: DEBUG - + ynh_clean_check_starting
2020-07-03 09:46:55,499: DEBUG - + '[' -n '' ']'
2020-07-03 09:46:55,501: DEBUG - + '[' -n '' ']'
2020-07-03 09:46:55,502: DEBUG - + exit 1
2020-07-03 09:46:55,543: ERROR - Could not install peertube: An error occurred inside the app installation script

etherpad

2020-07-03 23:17:46,298: DEBUG - + '[' -n 15194 ']'
2020-07-03 23:17:46,299: DEBUG - + kill -SIGTERM 15194
2020-07-03 23:17:46,301: DEBUG - + '[' -n /tmp/tmp.ItTHZNjWSV ']'
2020-07-03 23:17:46,302: DEBUG - + ynh_secure_remove /tmp/tmp.ItTHZNjWSV
2020-07-03 23:17:46,318: DEBUG - /usr/share/yunohost/helpers.d/getopts: line 214: 15194 Terminated              tail --follow=name --retry --lines=0 "$log_path" > "$templog" 2>&1
2020-07-03 23:17:46,319: DEBUG - + local 'forbidden_path=     /var/www     /home/yunohost.app'
2020-07-03 23:17:46,321: DEBUG - + '[' 1 -ge 2 ']'
2020-07-03 23:17:46,322: DEBUG - + [[ -z /tmp/tmp.ItTHZNjWSV ]]
2020-07-03 23:17:46,324: DEBUG - + [[      /var/www     /home/yunohost.app =~ /tmp/tmp\.ItTHZNjWSV ]]
2020-07-03 23:17:46,326: DEBUG - + [[ /tmp/tmp.ItTHZNjWSV =~ ^/[[:alnum:]]+$ ]]
2020-07-03 23:17:46,327: DEBUG - + [[ V = \/ ]]
2020-07-03 23:17:46,329: DEBUG - + '[' -e /tmp/tmp.ItTHZNjWSV ']'
2020-07-03 23:17:46,330: DEBUG - + rm --recursive /tmp/tmp.ItTHZNjWSV
2020-07-03 23:17:46,332: DEBUG - + '[' 1 -eq 1 ']'
2020-07-03 23:17:46,334: DEBUG - + ynh_replace_string --match_string=__LANGUAGE__ --replace_string=en --target_file=../conf/lang_mypads.sql
2020-07-03 23:17:46,349: DEBUG - + local delimit=@
2020-07-03 23:17:46,350: DEBUG - + match_string=__LANGUAGE__
2020-07-03 23:17:46,352: DEBUG - + replace_string=en
2020-07-03 23:17:46,354: DEBUG - + sed --in-place s@__LANGUAGE__@en@g ../conf/lang_mypads.sql
2020-07-03 23:17:46,356: DEBUG - + mysql -u etherpad_mypads -p********** etherpad_mypads
2020-07-03 23:17:46,357: DEBUG - + ynh_exit_properly
2020-07-03 23:17:46,359: DEBUG - + local exit_code=1
2020-07-03 23:17:46,360: DEBUG - + '[' 1 -eq 0 ']'
2020-07-03 23:17:46,362: DEBUG - + trap '' EXIT
2020-07-03 23:17:46,364: DEBUG - + set +o errexit
2020-07-03 23:17:46,365: DEBUG - + set +o nounset
2020-07-03 23:17:46,367: DEBUG - + sleep 0.5
2020-07-03 23:17:46,872: DEBUG - + type -t ynh_clean_setup
2020-07-03 23:17:46,874: DEBUG - + ynh_clean_setup
2020-07-03 23:17:46,875: DEBUG - + ynh_clean_check_starting
2020-07-03 23:17:46,877: DEBUG - + '[' -n '' ']'
2020-07-03 23:17:46,879: DEBUG - + '[' -n '' ']'
2020-07-03 23:17:46,880: DEBUG - + exit 1
2020-07-03 23:17:46,945: ERROR - Could not install etherpad_mypads: An error occurred inside the app installation script

I installed yunohost on a virtualbox machine and here are the answers to my own question:

ls -l / | grep var
drwxr-xr-x  13 root root  4096 Jul 12 20:38 var
ls -l /var | grep www
drwxr-xr-x  5 root root  4096 Jul 13 01:10 www
ls -l /var/www
total 8
drwxr-xr-x 10 etherpad_mypads etherpad_mypads 4096 Jul 12 20:51 etherpad_mypads
drwxr-xr-x  2 root            root            4096 Jul 12 20:33 html

Below are the commands I ran to fix my state on my non-Virtualbox server and I am able to install apps again.

I don’t recommend running these if you do not understand them. One place to learn about users and groups permissions is Linux Academy.

chgrp root /var
chgrp root /var/www
chmod 755 /var/www
chgrp root /var/www/html
chmod 755 /var/www/html

Anyways, I ran into errors installing PeerTube and NextCloud on both the Virtualbox and my server so yunohost is not for me right now. If I had the time I would contribute and see if I could help get them working.

For now it’s manual installations of the software I want on a vanilla server image for me. For anyone looking to learn more about that, DigitalOcean has many great articles for how to get started setting up and administering web services on an Ubuntu image.