Linux – How to create a socket with mknod correctly

linuxsocket

I try to create a socket for communication between uwsgi and nginx.

The difficulty is that I don't know what major and minor numbers I should specify:

v:/tmp# mknod wsgi_pgame.sock c
mknod: missing operand after `c'
Special files require major and minor device numbers.

And I don't know whether the device should be block or character.

Could you please help?

Best Answer

Mknod (mknod p, not c) creates a fifo, a unix socket. Unix sockets are different beasts and don't nead mknod (or root privileges for that matter). Configured properly, uwsgi will create the socket for you, you just need to make sure the permissions are right so nginx can use it. Something like this for a Debian-ish system.

shared-socket = 1
socket        = /tmp/uwsgi.sock
chmod_socket  = 600
chown_socket  = www-data
uid           = www-data
gid           = www-data