DEV Community

Aman Sharma
Aman Sharma

Posted on

1 1

How to deploy your Django Web App on AWS EC2 Instance

Hey you can deploy your website by following this link.

Here's a Youtube Video link

Just follow the exact steps and you'll do it within 30 minutes.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-venv
python3 -m venv venv
source venv/bin/activate
pip3 install django
git clone 'Your repo'
cd /yourRepo
pip3 install gunicorn
sudo apt-get install -y nginx
gunicorn --bind 0.0.0.0:8000 aoo.wsgi:application { to view the running app }

sudo apt-get install supervisor
cd /etc/supervisor/conf.d
sudo touch gunicorn.conf
data to enter -

[program:gunicorn]
directory=/home/ubuntu/resume/djangoResume
command=/home/ubuntu/venv/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/resume/app.sock djangoResume.wsgi:application

autostart=true
autorestart=true
stderr_logfile=/var/log/gunicorn/gunicorn.err.log
stdout_logfile=/var/log/gunicorn/gunicorn.out.log

[group:guni]
programs:gunicorn

sudo mkdir /var/log/gunicorn
sudo supervisorctl update
sudo supervisorctl reread

cd /etc/nginx/sites-available
sudo touch django.conf
paste below code there-

server {
server_name yourIp;
server_name www.yourDomain;
server_name yourDomain;

    location / {
            include proxy_params;
            proxy_pass http://unix:/home/ubuntu/path/app.sock;

    }

     location /static/ {
            autoindex on;
            alias /home/ubuntu/path/static/;
            }
    location /media/ {
            autoindex on;
            alias /home/ubuntu/path/media/;

sudo ln django.conf /etc/nginx/sites-enabled/
sudo nginx -t

►Website (created using Django) - https://www.amannvl.me
►Facebook - https://www.facebook.com/amannvl
►Instagram - https://www.instagram.com/amannvl/
►Twitter - https://twitter.com/amannvl

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay