Skip to content

Instantly share code, notes, and snippets.

@ErDmKo
Last active December 21, 2015 23:19
Show Gist options
  • Save ErDmKo/6381208 to your computer and use it in GitHub Desktop.
Save ErDmKo/6381208 to your computer and use it in GitHub Desktop.
nginx server conf and uwsgi for django project
server {
listen 80;
server_name www.<domain>;
return 301 $scheme://<domain>$request_uri;
}
server {
listen 80;
server_name localhost <ip> <domain>;
location ~* ^.+\.(xml|html|txt|png|jpg|gif|ico)$ {
root /home/<pr_name>/static;
}
location ~ ^/index.(html|php)$ {
if ($request_uri ~ ^/index.(html|php)) {
rewrite ^.*$ / permanent;
}
access_log /var/log/nginx/<pr_name>.access.log main;
error_log /var/log/nginx/<pr_name>.err.log;
location / {
uwsgi_pass unix:///tmp/uwsgi_<pr_name>;
include uwsgi_params;
}
location /static {
root /home/<pr_name>/static;
}
location /media {
root /home/<pr_name>/static;
}
}
/usr/bin/uwsgi \
--chdir /home/<pr_name>/<pr_name>/<pr_name>/ \
--socket /tmp/uwsgi_<pr_name> \
--chmod-socket \
--module wsgi \
--pythonpath /home/<pr_name>/<pr_name>/ \
--touch-reload /home/<pr_name>/reload \
--daemonize /var/log/uwsgi/<pr_name>.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment