|
|
| Line 2: |
Line 2: |
| == Prerequisites == | | == Prerequisites == |
|
| |
|
| === Install Python ===
| | See [[Django App Prerequisites for AWS Elastic Beanstalk]] |
| | |
| Check for python and pip, and their versions:
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ python --verison
| |
| $ pip --version
| |
| </syntaxhighlight>
| |
| | |
| ==== Python 3.x ====
| |
| | |
| Python 3.x is often invoked as `python3`.
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ python3 --verison
| |
| </syntaxhighlight>
| |
| | |
| If Python 3 is not installed:<ref>[http://stackoverflow.com/questions/27669927/how-do-i-install-python3-on-an-aws-ec2-instance How do I install python3 on an AWS instace] (Stackoverflow)</ref>
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ sudo yum list | grep python3
| |
| $ sudo yum install python34 # or relevant version
| |
| </syntaxhighlight>
| |
| | |
| === Create a virtual Python environment for the EC2 instance ===
| |
| | |
| Install `virtualenv` if needed:
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ which virtualenv
| |
| $ pip install virtualenv
| |
| </syntaxhighlight>
| |
| | |
| Create the virtual Python Environment<ref>[http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-common-steps.html#python-common-setup-venv Setting up a virtual Python environment] (AWS documentation)</ref>
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ virtualenv -p python3.4 /tmp/py34_nrose_env
| |
| </syntaxhighlight>
| |
| | |
| Where `py34_nrose_env` is a name that makes sense for the app's virtual environment.
| |
| | |
| Start the virtual environment:
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ . /tmp/eb_python_app/bin/activate
| |
| </syntaxhighlight>
| |
| | |
| Confirm the Python version:
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ python --version
| |
| </syntaxhighlight>
| |
| | |
| === Install AWS Elastic Beanstalk CLI <ref>[http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-common-steps.html#python-common-installing-ebcli Installing the AWS Elastic Beanstalk CLI] (AWS documentation)</ref> ===
| |
| | |
| <p class="alert alert-warning">I couldn't get the following command to work until I switched to the Python 3.4 virtual environment.</p>
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ pip install awsebcli
| |
| </syntaxhighlight>
| |
| | |
| Confirm the installation with `eb --version`
| |
| | |
| === Install Django<ref>[http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html#python-django-install Install Django] (Deploying a Django Application - AWS Elastic Beanstalk)</ref> ===
| |
| | |
| (Make sure to use the virtual Python 3 environment.)
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ pip install django
| |
| </syntaxhighlight>
| |
| | |
| Confirm the installation with
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ pip freeze | grep -i django
| |
| Django==1.9.2
| |
| </syntaxhighlight>
| |
| | |
| === Install Git ===
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ sudo yum install git-all
| |
| </syntaxhighlight>
| |
|
| |
|
| == Deploying a Django app == | | == Deploying a Django app == |