How we are deploying Django projects to AWS

How we are deploying Django projects to AWS

Allan Porras
Allan Porras May 29 2016 • 1 min read

Internally, we are constantly looking for the best way to deploy some Django projects to AWS.  Some people prefer to use automated process (yeah! automated deploys).

This is just a step. There are a lot way to do it. Here is the stack. Let’s go!

I personally prefer Google Cloud Platform. Probably I will write about that on this blog soon.

I’m using a EC2 instance, with Ubuntu.
I’m clonning the  Git repo under  /home/ubuntu by using the ubuntu user.


Virtual environment is an important requirement. I have used both virtualenv  and virtualenvwrapper; in this case I used virtualenvwrapper, and all Python and pip packages are installed in a separated folder.


Gunicorn is just an HTTP server for projects.I have started my Django project on server trough Gunicorn on a local hostname and port (http://localhost:8000).


I use Supervisor to convert my project in a daemon. That’s it. So, if I restart the server, this daemon will be started automatically.This is my  /etc/supervisor/conf.d/myproject.conf

stdout_logfile_maxbyes=20MB  is just a bash file to launch Django trough Gunicorn. Something like:

gunicorn myproject.wsgi:application -w 3 --bind= 


Nginx is very cool HTTP/Proxy server. I’m using Nginx as a proxy, to serve the local project to the web.I’ts like make enabled  localhost:8000  from Nginx is also serving all the Django static files, and make it visible from  /static.

server { listen 80; server_name; client_max_body_size 5M; charset utf8; keepalive_timeout 6; access_log /home/ubuntu/logs/nginx.access.log; error_log /home/ubuntu/logs/nginx.error.log; location / {  proxy_read_timeout 800;  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  proxy_set_header Host $host;  proxy_pass; } location /static {  alias /home/ubuntu/myproject/static;  autoindex on; }}

If you need help with your deployment or managing your stack, please contact us.

Request follow-up 🤙

About 4Geeks

Founded in 2012, 4Geeks is a global software engineering and revenue growth consulting firm for Fortune 500, Global 2000 and fast-growing SMBs. Provides top solutions to multiple industries including Retail, Healthcare, Banking & Financial Services, B2B SaaS, Manufacturing and Education. HQ in the USA, and delivery centers across Latin America.

Weekly Business Newsletter

Actionable Growth Hacks

Receive relevant news, advice, trends in your industry and invitations to exclusive events, direct to your inbox every week.

Subscribe on LinkedIn