Skip to content

Instantly share code, notes, and snippets.

@channprj
Forked from timmyomahony/nginx.conf
Created August 25, 2016 08:49
Show Gist options
  • Save channprj/5029c152a065a1b42f5127b739299387 to your computer and use it in GitHub Desktop.
Save channprj/5029c152a065a1b42f5127b739299387 to your computer and use it in GitHub Desktop.
Python, UWSGI, Supervisor & Nginx
upstream uwsgi {
ip_hash;
server 127.0.0.1:40000;
}
server {
listen 80;
server_name www.domain.com;
root /sites/mysite/;
access_log /sites/mysite/log/nginx/access.log;
error_log /sites/mysite/log/nginx/error.log;
location /media/ {
alias /sites/mysite/media/;
}
location /static/ {
alias /sites/mysite/static/;
}
location / {
include uwsgi_params;
uwsgi_pass uwsgi;
uwsgi_param UWSGI_PYHOME $document_root;
uwsgi_param UWSGI_CHDIR $document_root/project_root;
uwsgi_param UWSGI_SCRIPT confs.django_wsgi;
}
}
[program:uwsgi]
user = uwsgi
command=/opt/bin/uwsgi --xmlconfig=/sites/mywebsite/myproject/confs/uwsgi.xml
autostart=true
autorestart=true
stderr_logfile = /sites/mywebsite/log/uwsgi/err.log
stdout_logfile = /sites/mywebsite/log/uwsgi/out.log
stopsignal=INT
<uwsgi>
<socket>127.0.0.1:40000</socket>
<processes>2</processes>
<master/>
<post-buffering>4096</post-buffering>
<harakiri>20</harakiri>
</uwsgi>
import os,sys
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.production'
application = django.core.handlers.wsgi.WSGIHandler()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment