DEV Community

Aman Sharma
Aman Sharma

Posted on

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

Top comments (0)