Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uwsgi+nginx how to change group?

Tags:

nginx

uwsgi

im trying uwsgi+nginx+django tutorial, and got stuck there (link links directly to section where i got stuck) https://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html#if-that-doesn-t-work

nginx error.log says:

2015/03/09 13:44:51 [crit] 11642#0: *16 connect() to unix:///home/gaucan/temp/my_app/mysite.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///home/gaucan/temp/my_app/mysite.sock:", host: "localhost:8000"

and tutorial says to fix it, do the following: You may also have to add your user to nginx’s group (which is probably www-data), or vice-versa, so that nginx can read and write to your socket properly. But im linux noob and i don't know how to this, or how to find out if that group is www-data or not... already did some mess before with changing owner to some folders to user:"gaucan"

also i did skip in tutorial this step: You will need the uwsgi_params file, which is available in the nginx directory of the uWSGI distribution, or from https://github.com/nginx/nginx/blob/master/conf/uwsgi_params since i don't know which directory is nginx directory of the uWSGI distribution...

btw i use FEDORA if thats any help...

like image 576
waTEXmelon Avatar asked Nov 01 '22 08:11

waTEXmelon


1 Answers

To find the permissions of a file:

ls -al unix:///home/gaucan/temp/my_app/mysite.sock

That will print some columns of information, the first of which will be the unix permissions:

-rw-rw-r--   1 user group  1234 Mar 9 2015  name of file

The first dash is special, just ignore it. The next three characters represent the read, write, and exeute permissions of the User who owns the file. Next 3 represent the group who owns the file. The last 3 represent everyone else.

The nginx process needs to be able to write to that socket file.

You don't have to add your user to the same group as nginx, but you do need to allow proper permissions on the socket. Those instructions as written don't make 100% sense to me.

-- instructions to add your user to a group anyway --

To find the user of a process:

ps aux | grep nginx

One of the output columns will be the user of the nginx process

To find out what groups you belong to:

groups

That will print a space separated list of unix groups that you belong to.

To set a brand new list of groups that you belong to

sudo usermod -G group1,group2  username

Note that the groups are comma separated and they will wipe out any existing groups, so you need to re-type all the existing groups into that command with commas.

Alternatively, use the --append flag of usermod:

sudo usermod --append -G www-data username

You must completely logout and login again to gain the effect of the new groups. (There may exist a shortcut to reload your groups, but I'm not aware of one)

like image 77
chugadie Avatar answered Nov 08 '22 07:11

chugadie