How to Deploy Django Applications on Linode (Ubuntu 20.04 LTS)
I recently deployed a Django application to Linode and had quite some trouble getting everything to run smoothly. Below I offer a step-by-step manual to get things running on a Ubuntu 20.04 LTS image.
Before you start
- Make sure you have a functional Django app that you have tested with Django’s built-in development server.
python3 manage.py makemigrationslocally. (We’ll do the follow-up with
migratein the production environment).
- Push the complete project (e.g.
mysite/)to a remote repository like GitHub or Bitbucket. Make sure you include the migrations folder in your repo (don’t put them in
.gitignore!) and a
Create a Linode account and create a new Linode (i.e. a Virtual Private Server):
- Choose Distribution image: Ubuntu 20.04 LTS (which stands for “Long Term Support” and is more stable than 20.10)
- Choose region: [pick something close to you]
- Choose Linode Plan, Label and Root Password
- Choose Optional Add-ons
- Press “Create Linode”
When the Linode is created, go to the Network tab and take note of the following data, which we’ll need later on. I’ll be referring to these values as
- Linode IP address (e.g.
- Linode Reverse DNS (e.g.
Change local settings.py
Re-organize your local
settings.py file to easily switch from development to production settings, like so. (Take care to replace
Connect via SSH
Connect to your Linode via SSH as
root. (Take care to wait until your Linode virtual private server has booted and has the status “Running”):