How to create a socket with mknod correctly?

12,724

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
Share:
12,724

Related videos on Youtube

sergzach
Author by

sergzach

Updated on September 18, 2022

Comments

  • sergzach
    sergzach almost 2 years

    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?

  • GreyCat
    GreyCat about 6 years
    FIFO (AKA "pipe", shown as p in ls output) is not the same thing as UNIX socket (shown as = in ls output). Unfortunately, you can't create UNIX socket with mknod. This is mostly for historical reasons: i.e. normally, bind() call expects the node to not exist, so creation of UNIX socket node beforehand, prior to actual connection process, make little sense. That said, if you really want to create it, most modern netcat / nc variants can do that.