How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 22.04
Source: How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 22.04 (DigitalOcean)
Why I saved it
The reference walkthrough for deploying Django on a plain VPS without Docker: PostgreSQL, Gunicorn behind Nginx. Key ideas and my own reformulation come once I've worked through it.
Questions
- How does the tutorial run Gunicorn (systemd socket and service), and how does that compare with the containerized setup in Container Entrypoint Hardening and Gunicorn Worker Configuration?
- Which parts carry over to a Docker Compose deployment, and which only apply to a bare server?
References
- How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 22.04 - the article itself, on DigitalOcean Community.
- Django MOC - hub for Django notes.
Review cards
Flashcard In the tutorial's setup, what do the Gunicorn systemd socket and service each do?
The socket unit listens on /run/gunicorn.sock and starts the service on the first connection; the service unit runs Gunicorn with the Django app. Nginx proxies requests to the socket. To verify when working through the tutorial.
Quiz Which component is NOT part of the tutorial's bare-server stack?
- PostgreSQL
- Nginx as a reverse proxy
- Gunicorn under systemd
- Docker Compose
The tutorial installs everything directly on Ubuntu; Docker Compose belongs to the containerized setups elsewhere in the vault.