Deploying a Django app on AWS: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
Line 86: Line 86:
</syntaxhighlight>
</syntaxhighlight>


== Deploying a Django app
== Deploying a Django app ==
 
=== Installing and updating project files ===


`ssh` to the AWS server.
`ssh` to the AWS server.
Line 93: Line 95:


Use Git to pull from the project repository.
Use Git to pull from the project repository.
=== Installing Django app dependencies ===
See [[Defining Django App Dependencies]]


== Notes ==
== Notes ==

Revision as of 17:10, 7 February 2016

Prerequisites

Install Python

Check for python and pip, and their versions:

$ python --verison
$ pip --version

Python 3.x

Python 3.x is often invoked as python3.

$ python3 --verison

If Python 3 is not installed:[1]

$ sudo yum list | grep python3
$ sudo yum install python34 # or relevant version

Create a virtual Python environment for the EC2 instance

Install virtualenv if needed:

$ which virtualenv
$ pip install virtualenv

Create the virtual Python Environment[2]

$ virtualenv -p python3.4 /tmp/py34_nrose_env

Where py34_nrose_env is a name that makes sense for the app's virtual environment.

Start the virtual environment:

$ . /tmp/eb_python_app/bin/activate

Confirm the Python version:

$ python --version

Install AWS Elastic Beanstalk CLI [3]

I couldn't get the following command to work until I switched to the Python 3.4 virtual environment.

$ pip install awsebcli

Confirm the installation with eb --version

Install Django[4]

(Make sure to use the virtual Python 3 environment.)

$ pip install django

Confirm the installation with

$ pip freeze | grep -i django
Django==1.9.2

Install Git

$ sudo yum install git-all

Deploying a Django app

Installing and updating project files

ssh to the AWS server.

Invoke the virtual Python 3.x environment.

Use Git to pull from the project repository.

Installing Django app dependencies

See Defining Django App Dependencies

Notes

See also

References

  1. How do I install python3 on an AWS instace (Stackoverflow)
  2. Setting up a virtual Python environment (AWS documentation)
  3. Installing the AWS Elastic Beanstalk CLI (AWS documentation)
  4. Install Django (Deploying a Django Application - AWS Elastic Beanstalk)