[Django]-When setting up uwsgi and nginx, do I have to create the socket file myself?

2👍

That socket file will be created automatically by uwsgi. If you look further in the documentation you linked to, you’ll find instructions to put the following line in your mysite_uwsgi.ini:

socket          = /path/to/your/project/mysite.sock

This tells uwsgi where to create the socket for your application. The following line from your nginx configuration:

server unix:///path/to/your/mysite/mysite.sock; # for a file socket

tells nginx where to look for the socket. The two paths in each configuration file must be identical (or resolve to the same file).

As chuk2bp mentioned, the socket file is a communication channel. In this case it allows nginx to talk to uwsgi.

👤Louis

3👍

.sock files are unix sockets (also called IPC sockets as well) and are programmatically created to allow information to be exchanged between processes. In this case, mysite.sock allows for information to be exchanged between uwsgi and nginx. Sockets, when applicable, are used alternatively to ports which have much more overhead. For the purposes of similarity, think “piping” between processes.

This article in particular helped me understand sockets much more effectively. Give it a read!

0👍

as @Louis’s answer.

server unix:///path/to/your/mysite/mysite.sock; # for a file socket

You just change

unix:///path/to/your/mysite/mysite.sock;

to

unix:///home/h/workspace/sun-asterisk/POC-makeup/deploy-tutorial/nginx-tutorial/mysite/mysite.sock;

Note: /home/h/workspace/sun-asterisk/POC-makeup/deploy-tutorial/nginx-tutorial/mysite is my project path.

Leave a comment