"How I Successfully Deployed My Django Project on AWS: A Step-by-Step Guide for Beginners"

After completing my Django project, I wanted to deploy to AWS. Here are my steps to deploy.
Step 1: Create an AWS account (root user) because the root user has unrestricted access to all the AWS resources and services.
Step 2: For authentication, install an Authentication app for your device. Whenever you want to use AWS after signing in with the root user, then it asks the MFA (Multi-Factor Authentication) code.
Step 3: Then create an EC2 (Elastic Compute Cloud) instance for running applications on the AWS.
Step 4: Then create an instance and name it, then choose the OS which platform to run your application. Here I chose Ubuntu.
Step 5: Launch the instance, then on launching page go to connect. They are open to Ubuntu OS.
sudo apt update
git clone < project git url >
sudo apt install python3-pip python3-venv -y
python3 -m venv venv
source venv/bin/activate
pip install django
py manage.py runserver
py manage.py makemigrations
py manage.py migrate
py manage.py createsuperuser
py manage.py runserver 0.0.0.0:<port no>
Step 6: These commands are already known what it did except that last command.
Step 7: Then, for instance, the link gives that ipv4 address, when it clicks, it shows web page.
Step 8: So we can edit inbound rules in the security group to create a new <port no> then it mentions that last line.
Step 9: Again, when we run that last one it gives an error again. Now we can change that port address from https to http. So it runs perfectly.
But when i deploy it on AWS, I can face many challenges and In fact, I can retry 5 to 6 times .
Then I finally understand when we run a Django project locally, we don't need static files, but when deploy on AWS we must want static files.
Add these settings to my settings file:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
Then, again that command runs it works properly.
If you’re interested, check out my GitHub repository here.
Subscribe to my newsletter
Read articles from Arunmathavan K directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
