DEV Community

Cover image for Deploying a Production-ready Django app on AWS

Deploying a Production-ready Django app on AWS

Ryuichi Miyazaki on August 26, 2020

In this tutorial, I will be going over to how to deploy a Django app from start to finish using AWS and EC2. Recently, my partner Tu Vo and I launc...
Collapse
 
blakegreendev profile image
Blake Green

Still in beta but now you can run your Docker compose files directly to Amazon ECS.

docs.docker.com/engine/context/ecs...

It abstracts a lot of the manual set up in the AWS console.

Collapse
 
rmiyazaki6499 profile image
Ryuichi Miyazaki

Awesome! Thanks for the heads up!
I will have to give it a try and update the guide.

Collapse
 
jsauceda profile image
Jorge Sauceda

Hi Ryuichi! Thanks for your post. I followed it, and I can browse to my django project. However, the admin site does not load any CSS. I collected the static files and double checked the nginx config to no avail. Any hints?

Collapse
 
jsauceda profile image
Jorge Sauceda • Edited

Don't worry! I found my mistake: the /home/user directory did not have execution rights for its user group and others. So, I changed the permissions by running:

  • $ chmod 755 /home/user/
  • $ chmod 755 /home/user/project_directory/static/
  • $ chmod 644 /home/user/project_directory/static/* according to the recommendations in here: nginxlibrary.com/403-forbidden-error/. Now the www-data user has execution rights, can access my static files and my django project works fine with nginx.
Collapse
 
rmiyazaki6499 profile image
Ryuichi Miyazaki

Hi Jorge!
Sorry for the late response and for not being able to help you. I wrote this guide a couple of years ago so some things might be out of date. Your comment will help anyone who runs into the same issue again so I really appreciate your comment!

Collapse
 
pieterk profile image
Pieter K • Edited

Hi Ryu, saw your profile on Twitter. I'm was just recently deployed a django app to a VPS. Though I followed a different method. Curious whether you have recommendation on project deployment once a project is up and running. (pulling newest version from github repo to server)

Good stuff btw!

Collapse
 
2jn profile image
Jose Navas

I'm launching my own app to AWS with you setup, thanks a lot for sharing. I have one question though. Don't you need RDS when building for production ?

Collapse
 
rmiyazaki6499 profile image
Ryuichi Miyazaki

Hi Jose!
Thank you for checking out my guide!
Good point and I think I did not mention it but yes using either RDS or some other database service would be necessary.

For my personal project, I used ElephantSQL for a Postgres database as it was free but you are free to use whichever database works best for you!

I might do a follow-up guide on setting up a database with AWS when I have the time...

Collapse
 
2jn profile image
Jose Navas

Thanks for replying, I'll be waiting for your follow-up. Keep it up!

Collapse
 
aditya0811 profile image
Aditya Mahajan • Edited

I failed to start guvicorn, its saying failed to gunicorn.socke failed, also in status its inactive

Collapse
 
vishnue1993 profile image
vishnue1993

is it necessary to turn on the 8000 port on inbound security group, once we set up Nginx/Apache for the static contents. The port for apache/nginx could get the requests right?

Collapse
 
faridlu profile image
Farid Chowdhury

yes it is necessary to add 8000 port on inbound security group..

Collapse
 
nikhilsegu profile image
Sai Nikhil

I'm just a beginner to this, can anyone explain why the docker is being used here?