$ sudo apt-get update -y
$ sudo apt-get upgrade -y
$ sudo apt-get install -y python3 python3-dev python3-pip
$ sudo apt-get install -y git vim
$ sudo apt-get install -y nginx
$ pip3 install django gunicorn
$ django-admin startproject <PROJECT_NAME>
...
# Django 프로잭트 설정
...
# 우분투 20.04
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo apt-get update
# 우분투 16.04, 18.04
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository universe
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
# 공통
$ sudo apt-get install certbot python3-certbot-nginx
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py collectstatic
$ which gunicorn
## GUNICORN 위치 확인
$ sudo vi /etc/systemd/system/gunicorn.service
## 서비스 파일 생성
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=<USER_NAME>
Group=www-data
WorkingDirectory=<YOUR_PROJECT_PATH>
ExecStart=<GUNICORN_PATH> \
--workers 3 \
--bind 0.0.0.0:8000 \
<PROJECT_NAME>.wsgi:application
[Install]
WantedBy=multi-user.target
$ sudo systemctl start gunicorn
$ sudo systemctl enable gunicorn
# sudo vi /etc/nginx/sites-available/default
# configuration of the server
server {
listen 80;
listen [::]:80;
server_name <YOURE_DOMIAN>;
charset utf-8;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /<YOUR_PROJECT_PATH>/staticfiles/;
}
location / {
include proxy_params;
proxy_pass http://<YOUR_DOMAIN>:8000;
}
# max upload size
client_max_body_size 75M;
}
$ sudo nginx -t
$ sudo systemctl restart nginx
$ sudo certbot --nginx -d <YOUR_DOMAIN>
# 도메인 적용
...
# 문의의 맞춰 진행
...
$ sudo certbot renew --dry-run
# 자동 갱신
🎈 Let's Encrypt : https://letsencrypt.org/ko/