Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
development:python:django:deploy [2020/02/27 17:10]
kalenpw created
development:python:django:deploy [2021/06/29 15:02] (current)
kalenpw
Line 1: Line 1:
 ====== Deploy ====== ====== Deploy ======
 +
 +----
 +  - Set up virtualenv
 +  - Install gunicorn ''pip install gunicorn''
 +  - Set ''ALLOWED_HOSTS = 'domain.com%%'%%'' in ''project/settings.py''
 +  - Set ''STATIC_ROOT = os.path.join(BASE_DIR, 'static')'' in ''project/settings.py''
 +  - Collect static images to one directory ''python manage.py collectstatic''
 +  - Run gunicorn ''gunicorn %%--%%daemon %%--%%workers 3 %%--%%bind unix:/web/blog.kalen.pw/kalenpw.sock kalenpw.wsgi''
 +
 +Example Nginx config
 +<file nginx blog.kalen.pw>
 +server {
 +    server_name blog.kalen.pw;
 +
 +    location = /favicon.ico { access_log off; log_not_found off; }
 +
 +    location /static/ {
 +        root /web/blog.kalen.pw;
 +    }
 +
 +    location / {
 +        include proxy_params;
 +        proxy_pass http://unix:/web/blog.kalen.pw/kalenpw.sock;
 +    }
 +
 +    listen 443 ssl; # managed by Certbot
 +    ssl_certificate /etc/letsencrypt/live/kalen.pw/fullchain.pem; # managed by Certbot
 +    ssl_certificate_key /etc/letsencrypt/live/kalen.pw/privkey.pem; # managed by Certbot
 +    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
 +    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
 +}
 +
 +server {
 +    if ($host = blog.kalen.pw) {
 +        return 301 https://$host$request_uri;
 +    } # managed by Certbot
 +
 +    server_name blog.kalen.pw;
 +    listen 80;
 +    return 404; # managed by Certbot
 +}
 +
 +</file>
 +----