Django App Deployment

Steps to Deploy Django

  1. Update the repository

sudo apt update
  1. Install the required packages

sudo apt install nginx
sudo apt install python3-pip
sudo pip3 install gunicorn
sudo apt install certbot
sudo apt install python3-certbot-nginx
  1. Clone your Django project on EC2 instance and install its dependencies:

git clone https://github.com/<username>/<project-name>.git
cd <project-name>
pip3 install -r requirements.txt
  1. Configure Gunicorn to run your Django application:

cd <project-folder>
gunicorn --workers 3 --bind unix:/tmp/gunicorn.sock <project-name>.wsgi:application
  1. Create Nginx server block to proxy requests to Gunicorn:

Last updated

Was this helpful?