- Add
pi
to thewww-data
group using the commandsudo adduser pi www-data
- Add
www-data
to thepi
group using the commandsudo adduser www-data pi
- Change the permission of the directory and everything in it so that it's readable and writable by the group. Use the command
sudo chmod -R 775 /var/www
. - Since user
pi
is part ofwww-data
group, doing this allows the pi to modify files. - Since user
www-data
is part ofpi
group, this allows nginx to read files created bypi
. - Confusing? This is because users
www-data
andpi
have their own groups also namedwww-data
andpi
. -
Make sure everything in the folder is owned by
www-data
.-
sudo chgrp -R www-data /var/www
-
Oder:
- sudo chmod g+s /var/www
- sudo chmod 775 /var/www
- sudo chown -R www-data:www-data /var/www
useradd Example – Add a new user to secondary group
You need to the useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it. The syntax is as follows:
useradd -G {group-name} username
usermod example – Add a existing user to existing group
Add existing user tony to ftp supplementary/secondary group with the usermod command using the -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option:
# usermod -a -G ftp tony