Sushant
Sushant

Reputation: 3669

Deploying Django With AWS

So I am trying to deploy my django app(which mostly has REST Apis) but when I use Amazon CLI, I end up having Fedora instance, while I want to use Ubuntu instance.

So I tried to do this, I made an ubuntu instance, made a repository of my code, installed git on ubuntu and cloned the code from git to ubuntu. Next thing, I installed all the requirements.txt dependencies and everything is in virtualenv and working fine.

But here's the catch, python manage.py runserver runs it on localhost(not really surprising). So the question is, how to serve those apis(not on localhost)?

Upvotes: 0

Views: 143

Answers (3)

silent_grave
silent_grave

Reputation: 628

DO NOT use django development server in production. It is not built for that use.

Instead use something like elastic beanstalk that'll help you deploy out of box scalable django apps. Here's a good step-by-step tutorial for that: https://www.trysudo.com/deploying-django-app-on-aws-using-elastic-beanstalk/

Upvotes: 0

Mad Wombat
Mad Wombat

Reputation: 15105

As mentioned in the other answer, runserver command is only meant for local development. You can, in fact, make it listen on external interfaces by running it as python manage.py runserver 0.0.0.0:8000, but it is a bad idea. Configuring nginx+uwsgi to run a Django app is very easy. There are multiple tutorials and guides available for this. Here is the official uWSGI guide http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

Upvotes: 0

masnun
masnun

Reputation: 11906

Don't use the runserver command on production. It's meant for local development only.

On production, you need to setup an application server (uwsgi / gunicorn) and then use nginx as a reverse proxy.

Digital Ocean articles are pretty good - https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-14-04

(The same stuff apply for AWS as well)

Upvotes: 3

Related Questions