본문 바로가기

Python/Django

Django Deployment with Nginx and Gunicorn

728x90
반응형

 

 

1. Nginx 설치, 설정

 

설치

sudo apt-get update
sudo apt-get install nginx

설정

sudo nano /etc/nginx/sites-available/default
server {
    listen 80;
    server_name your_domain_name.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

 설정후 nginx 재시작

sudo systemctl restart nginx

 

 

2. Gunicorn

 

설치

sudo apt-get install gunicorn

 

gunicorn 실행

gunicorn --bind 127.0.0.1:8000 [--workers 2] project_name.wsgi:application

 

728x90
반응형