- Add
pito thewww-datagroup using the commandsudo adduser pi www-data - Add
www-datato thepigroup 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
piis part ofwww-datagroup, doing this allows the pi to modify files. - Since user
www-datais part ofpigroup, this allows nginx to read files created bypi. - Confusing? This is because users
www-dataandpihave their own groups also namedwww-dataandpi. -
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
