Deploy Django on AWS EC2

set up instance

First, you need to have an AWS IAM account, and set up and instance.
Next, you can SSH into the instance with ssh -i key.pem end_point
Once you are inside the instance, you have to set up your environment.

set up dev environment

Run sudo apt-get install python-pip to install pip.
Run pip install -r requirements.txt to install your environment. If you have database migrations, run them too.
Then change the ALLOWED_HOSTS inside django settings.py to the IP and domain name of server
Don’t forget to open the access of security group of 8000 for testing.
To test if it’s working, run python manage.py runserver to test if it works.

set up nginx

sudo apt-get install nginx
Open the browser to see nginx default page.

Set up gunicorn

pip install gunicorn
write gunicorn into a systemctl
sudo systemctl restart gunicorn

set up MySQL

sudo apt-get install libmysqlclient-dev
set up DB credentials in settings.py