Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting started with Django on Amazon Web Services [closed]

Tags:

I'm starting to migrate a few applications to Amazon Web Services. My applications are Python/Django apps, running over MySQL.

I plan on using EC2 and EBS for starters.

I'm looking for a few things:

  1. A good step-by-step tutorial explaining how to deploy Django on AWS. I've looked around, but most tutorials are from 2 years ago, so I'm worried they're outdated.

  2. I'm trying to understand, with which AMI should I start? I know there's a BitNami AMI that comes preconfigured with Django goodiness, but I've seen a lot of other sources say you should start with a basic (clean) linux box and install everything yourself. Why?

  3. Are there any other important things I should be thinking about? I have very little sysadmining experience (the apps are currently on WebFaction), so I'm not sure what I should be thinking about.

A few extra points:

  • I plan on running several applications on the same EC2 instance, I assume that's possible?
  • I'm using virtualenv to separate between the various apps right now, I assume I can continue doing the same on the EC2 instance?

Thanks!

like image 205
Edan Maor Avatar asked Dec 20 '10 10:12

Edan Maor


People also ask

Is AWS good for Django?

Amazon Web Services (AWS) provides EC2 (Elastic Compute Cloud) which is the most popular choice to host Django web applications.

Can we host Django website on AWS?

This tutorial walks through the deployment of a default, autogenerated Django website to an AWS Elastic Beanstalk environment running Python. This tutorial shows you how to host a Python web app in the cloud by using an Elastic Beanstalk environment.


2 Answers

There is nothing "special" with EC2 here. It just provides bare (or generally preconfigured from custom AMI) system instance - you have access to whole virtualized system, so you can safely break things on your own. Think about it as a specific VPS.

You have to prepare deployment by yourself, which is not so difficult - just follow the documentation. I'd advice to run with basic linux distro and add needed stuff than to rely on some preconfigured image. As for you questions:

  1. You need to do two things: setup your instance (accounts, needed software, other custom setup, so some linux administration guide should be handy) and prepare django app deployment (deploy python code, hook up to web server). For the latter, general deployment instructions for django can be applied here ( http://docs.djangoproject.com/en/dev/howto/deployment/ ).

  2. Start with AMI with your favorite linux distro, and then add necessary software from it's repository.

  3. Mount and use EBS as soon as possible for all your data. When rebooted, EC2 instance will wipe out all it's data, so be prepared for this. Do system snapshots to AMI to have quick recovery on failure.

Yes, you can deploy several applications on one instance, but mind that EC2 instance is virtualized (with quite high "virtualization tax" imo, especially for smaller instances), so you might run into general performance problems. Assume that you'd need migrate to bigger instance/multiple instances after some time.

Virtualenv should be your default deployment tool. Yes, you can use it here too.

like image 99
cezio Avatar answered Oct 09 '22 09:10

cezio


You can follow the official documentation of setting up Amazon ec2 instance: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance_linux.html

You should start with an AMI that you are familiar with. For example, if you use Ubuntu, you can just use one of the Ubuntu AMI in the recommended page. I didn't use the BitNami server and my Django site is deployed smoothly.

If you are using Apache server, just follow the instructions on the official Django doc: https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/

I tried quite a few blogs but as you said, they are outdated. Just use the official docs and it will save you a lot of time.

like image 33
Yulun Avatar answered Oct 09 '22 07:10

Yulun