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 https://bit.ly/3ddPqVu
Step 2 $ python manage.py 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 manage.py migrate
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 manage.py createsuperuser
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 manage.py runserver
Once the server is hosted, head over to http://127.0.0.1:8000/products/ for the App.That was pretty simple, right?
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
select instance type t2-micro (make sure free tier eligible) and create new key pair
Select launch Instance
If Instance created Succesfully you can view instance
Check instance is running and check status 2/2 passed
Now select security and edit inbound rule
In this Security setting add rules and edit inbound rule select custom TCP--Port range 8000 and source
port 0.0.0.0 it will allow excess to anywhere click save rules
Now go back to your EC2 page select your instance and right click connect
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
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 ec2-3-92-214-213.compute-1.amazonaws.com (Enter Your Public DNS)
you will connect to AWS EC2 Ubuntu server
make sure git install into your ubuntu server before cloning github project type or copy this command in your terminal
git clone https://github.com/prakashsanjay/My-Shopping-Mart.git and find your project by typing ls command you will fimd My_Shopping_mart
now go to settings.py file
vim settings.py press enter
make sure Python and Django both are installed in your AWS linux
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 settings.py file in pyshop folder
you can change allowed host from there as well.
Python3 manage.py runserver 0.0.0.0:8000
CTRL + CLICK 0.0.0.0:8000
Once the server is hosted, head over to http://0.0.0.0:8000/products/ for the App.and our django app now running into AWS EC2 server
That was also pretty simple, right?
thanks & regards