WSGI ASGI supervisor nginx daphne gunicorn
#> apt -y install build-essential git wget curl unzip python3-venv python3-pip
#> apt -y install libz-dev libjpeg-dev libfreetype6-dev python-dev
#> apt -y install supervisor nginx redis openssl libnss3-tools ssl-cert
#> apt -y install certbot python3-certbot-nginx
#> apt -y install iptables fail2ban
#> apt -y install sqlite3
#> openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
#> adduser shop
#> adduser shop www-data (ajouter shop au groupe de nginx)
Copier par ftp ou git le projet derrière /home/shop
#> su - shop
On se retrouve donc en donc /home/shop
[program:shop]
directory = /home/shop
command=/home/shop/.venv/bin/gunicorn
--chdir /home/shop/demo
--bind 127.0.0.1:8000
--user shop
--group www-data
--log-level error
demo.wsgi:application
user=root
stopasgroup=true
stopsignal=SIGINT
autostart=true
autorestart=true
redirect_stderr=true
redirect_stdout=true
#> supervisorctl reread #> supervisorct update
#> supervisorct restart shop
# virtualhost
server {
if ($host = shop.domain.com) {
return 301 https://$host$request_uri;
}
listen 80;
listen [::]:80;
server_name shop.domain.comg;
return https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name shop.domain.com;
set $base_path /home/shop;
keepalive_timeout 5;
client_max_body_size 4G;
access_log /var/log/nginx/shop.domain.com-access.log;
error_log /var/log/nginx/shop.domain.com-error.log;
ssl_certificate /etc/letsencrypt/live/shop.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/shop.domain.com/privkey.pem;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
set $root_path $base_path/demo;
root $root_path;
location /static/ {
alias $root_path/staticfiles/;
}
location /media/ {
alias $root_path/media/;
}
location /favicon.ico {
alias $root_path/staticfiles/img/logo.png;
}
location /robots.txt {
alias $root_path/staticfiles/robots.txt;
}
location / {
include proxy_params;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:8000;
}
}
#> systemctl restart nginx
INSTALLED_APPS = [
'daphne',
...
]
[program:demo]
directory = /home/shop
command=/home/shop/.venv/bin/daphne
--bind 127.0.0.1
--port 8000
--access-log -
--proxy-headers
demo.asgi:application
user=root
stopasgroup=true
stopsignal=SIGINT
autostart=true
autorestart=true
redirect_stderr=true
redirect_stdout=true