I've recently installed nginx on my dev machine with Ubuntu 12.04.
I am currently logged in as myuser and after installing nginx I setup the following file permissions (nginx www folder was owned by root so I wanted to change that so I can edit files with myuser):
# add myuser to nginx group
sudo usermod -a -G www-data myuser
# change ownership for www folder to nginx user (www-data)
chown -R www-data:www-data /usr/share/nginx/www
chmod -R 775 /usr/share/nginx/www
Then I go to /usr/share/nginx/www and try to create a new folder/file. I always get Permission denied.
Here is a listing of the folder:
drwxrwxr-x 2 www-data www-data 4096 Apr 29 11:01 .
drwxrwxr-x 3 www-data www-data 4096 Apr 29 11:01 ..
-rwxrwxr-x 1 www-data www-data 383 Jul 7 2006 50x.html
-rwxrwxr-x 1 www-data www-data 151 Oct 4 2004 index.html
Everything seems to be fine here. The only thing weird I noticed is with the id command for myuser.
uid=1000(myuser) gid=1000(myuser) groups=1000(myuser),4(adm),20(dialout),24(cdrom),46(plugdev),116(lpadmin),118(admin),124(sambashare)
As you can see the groups www-data (id=33) is not shown with id command. But if I try
id -G myuser
1000 4 20 24 33 46 116 118 124
With the latest command the group id 33 is displayed for myuser, which makes me think this user is actually in the www-data group.
Does anyone has an idea why I cannot write in the /usr/share/nginx/www folder as myuser ?
Best Answer
In order to get
www-data
group permissions you need to change the effective group ofmyuser
.Issue
and this should enable you to write in
/usr/share/nginx/www
.It seems to me that the output of
id
will be updated (in Ubuntu) after you first change your group.