20.3. Deploy Nginx and uWSGI
File socket:
server unix:///data/myproject/myproject.sock;
TCP socket:
server 127.0.0.1:8000;
File sockets are a bit faster and can be more secure (no TCP overhead)
20.3.1. Nginx
File /etc/nginx/conf/myproject.conf
:
upstream django {
server unix:///data/myproject/myproject.sock;
}
server {
listen 80;
server_name example.com www.example.com;
charset utf-8;
client_max_body_size 75M; # max upload size
location /media {
alias /data/myproject/media;
}
location /static {
alias /data/myproject/static;
}
location / {
uwsgi_pass django;
}
}
20.3.2. uWSGI
File /etc/uwsgi/config.ini
:
[uwsgi]
master = true
processes = 10
vacuum = true # clear environment on exit
socket = /data/myproject/myproject.sock
chmod-socket = 664
chdir = /data/myproject/
module = myproject.wsgi
home = /data/myproject/venv-py313