DEV Community 👩‍💻👨‍💻

Cover image for Deploy My-Shopping-Mart Django App in AWS EC2
Sanjay Prakash
Sanjay Prakash

Posted on

Deploy My-Shopping-Mart Django App in AWS EC2

Prequisite to Build & Deploy Django App in AWS EC2

  1. OS Linux-Ubuntu (Windows ,Mac)
  2. Visual Studio Code
  3. Python
  4. Django
  5. Bootstrap

Steps to run this Shopping-Mart Website in your local host
To get this repository, run the following command inside your git enabled terminal

Step 1 $ git clone

Step 2 $ python makemigrations

This will create all the migrations file (database migrations) required to run this App.

Step 3 Now, to apply this migrations run the following command

$ python migrate

Step 4

One last step and then our ecoomerce Shopping Mart website will be live. We need to create an admin user to run this App. On the terminal, type the following command and provide username, password and email for the admin user

$ python createsuperuser

Step 5

Now let's make the App live. We just need to start the server now and then we can start using our simple ecoomerce Shopping Mart. Start the server by following command

$ python runserver

Step 6

Once the server is hosted, head over to for the App.That was pretty simple, right?

Screenshot of website

How To Deploy Django Application in AWS EC2

Django comes with a development server that helps run Django projects in localhost. However, to make your web application available worldwide you will need a host machine. Amazon Web Services (AWS) provides EC2 (Elastic Compute Cloud) which is the most popular choice to host Django web applications.

Creating EC2 Instance With Ubuntu

Step 1: Select EC2 From AWS Console and click lauch Instance


Step 2: Name your Instance and Select Ubuntu


Step 3:
select instance type t2-micro (make sure free tier eligible) and create new key pair


Step 4:

Select launch Instance


Step 5:

If Instance created Succesfully you can view instance


Step 6:

Check instance is running and check status 2/2 passed


Step 7

Now select security and edit inbound rule


Step 8:

In this Security setting add rules and edit inbound rule select custom TCP--Port range 8000 and source
port it will allow excess to anywhere click save rules


Step 9:

Now go back to your EC2 page select your instance and right click connect


Step 10:

Now open your ubuntu terminal & locate your private key file. The key used to launch this instance is YOUR_KEY_NAME.pem file

in my case my pem file is in Download folder

cd Downloads

Run this command, to ensure your key is not publicly viewable.

chmod 400 WRITE_YOUR_KEY_NAME.pem

Connect to your instance using its Public DNS:

sudo (Enter Your Public DNS)

you will connect to AWS EC2 Ubuntu server

Screenshot from 2022-08-03 00-13-12

Step 11


cd My_Shopping_Mart

make sure git install into your ubuntu server before cloning github project type or copy this command in your terminal

git clone and find your project by typing ls command you will fimd My_Shopping_mart

Screenshot from 2022-08-03 00-23-49

Step 12

now go to file

cd pyshop


vim press enter

make sure Python and Django both are installed in your AWS linux


Step 13

press i to insert
than scrool down to Allowed Hosts [ ] empty box means your local host. now
enter asterisk ['*'] it will allow any ip address or [you can enter your EC2 publiv IP ]
press esc button
:wq press enter
you can also update it from vs code project folder locate file in pyshop folder
you can change allowed host from there as well.

Screenshot from 2022-08-03 11-26-13

Step 14
Run server

Python3 runserver


Step 15


Once the server is hosted, head over to for the App.and our django app now running into AWS EC2 server
That was also pretty simple, right?

Screenshot from 2022-08-03 11-20-15

thanks & regards
Happy Learning

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.