This post provides tutorials on how to deploy a Django application on a server running Ubuntu.
Softwares needed to set up a server for Django application:
- Virtualenv & Virtualenvwrapper / Conda
Nginx will face the outside world. It will serve media files (images, CSS, etc.) directly from the file system. However, it can’t talk directly to Django applications; it needs something that will run the application, feed it requests from the web, and return responses.
That’s Gunicorn‘s job. Gunicorn will create a Unix socket, and serve responses to Nginx via the wsgi protocol – the socket passes data in both directions:
The outside world <-> Nginx <-> The socket <-> Gunicorn
All this family will live into a Virtualenv. Already wondered why Virtualenv is so useful when you develop Pythons’s applications? Continue to read and you will understand.
Before you start
- Set up Django, Nginx and Gunicorn in a Virtualenv controled by Supervisor (A tutorial to seting up a django website in production.) — PDF
- How to Deploy a Django Application to Digital Ocean (Oct 14, 2016)
- Anaconda + Django + Apache (Jul 14, 2015 )
- Best Practices with conda – Open Source Answers
- How to create Django project in Anaconda — PDF
- How To Create A Django Project In Anaconda Very Easily (PDF if it is not retrievable)
- Setting up Django with Nginx, Gunicorn, virtualenv, supervisor and PostgreSQL (Jun 9th, 2013)
I assume you have a server available on which you have root privileges. I am using a server running Debian 7, so everything here should also work on an Ubuntu server or other Debian-based distribution. If you’re using an RPM-based distro (such as CentOS), you will need to replace the
aptitude commands by their
yum counterparts and if you’re using FreeBSD you can install the components from ports.