0

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)?

2
  • 1
    Have you not read any of the extremely comprehensive docs on deployment? There is no way you would ever want to use runserver in a deployment scenario. Commented Oct 17, 2016 at 17:06
  • You get Fedora instead of Ubuntu because you are not picking the right AMI. The official Ubuntu AMIs can be found here aws.amazon.com/marketplace/… Commented Oct 17, 2016 at 17:22

3 Answers 3

3

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)

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.