This is an old revision of the document!


Deploy


  1. Set up virtualenv
  2. Install gunicorn pip install gunicorn
  3. Set ALLOWED_HOSTS = 'domain.com' in project/settings.py
  4. Set STATIC_ROOT = os.path.join(BASE_DIR, 'static') in project/settings.py
  5. Collect static images to one directory python manage.py collectstatic
  6. Run gunicorn gunicorn --daemon --workers 3 --bind unix:/web/blog.kalen.pw/kalenpw.sock kalenpw.wsgi

Example Nginx config

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
}