Django Deployment to AWS Elastic Beanstalk Django.How

Author avatar wrote on 26/05/2022

What is AWS Elastic Beanstalk?

1.Preparing for AWS

Prepare to use AWS virtual environment

pip3 install virtualenv awsebcli

Create virtual environment outside the project

cd ..

virtualenv eb-vert

Activate virtual environment



You should try executing Set-ExecutionPolicy Unrestricted -Force in Your Power Shell.

NB: Remember to launch Power Shell as administrator.

Also make sure you use Scripts\Activate.PS1

Prepare the Virtual environment

pip install django pillow psycopg2

2. Deployment to AWS

Follow the official documentation

Check the list of installed apps

pip freeze

Prepare the requirement file

pip freeze > requirements.txt

Note: To check/change the file contents nano filename.txt on mac Linux notepad filename.txt on windows

Prepare .ebextensions for AWS

inside your project type mkdir .ebextensions

type ls to see it, if you could not see it type ls -a

Configure Django in .ebextensions

Create a file notepad .ebextensions/django.config

Add code

    WSGIPath: prject-name/
Collect Static

python collectstatic

then deactivate

Deploy your site with the EB CLI

Make sure Built-in SSH in Windows 10 is activated

settings → updates and security → for developers → Developer Mode

Activate SSH client: settings → apps → Optional features → add a feature → OpenSSH Server & OpenSSH Client → Install

Initialze AWS Project

eb init -p python-3.6 project-name