Created
June 22, 2013 19:49
-
-
Save kcoyner/5842340 to your computer and use it in GitHub Desktop.
Virtual host setup with django, uwsgi and nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[uwsgi] | |
vhost = true | |
plugins = python | |
socket = /run/uwsgi/app/ilovenatalia.net/ilovenatalia.net.socket | |
master = true | |
enable-threads = true | |
processes = 2 | |
module = ilovenatalia.uwsgi:application | |
home = /home/kcoyner/.virtualenvs/ilovenatalia | |
chdir = /opt/django_apps/ilovenatalia | |
uid = www-data | |
gid = www-data | |
env DJANGO_SETTINGS_MODULE=ilovenatalia.settings | |
pid = /run/uwsgi/app/ilovenatalia.net/pid | |
harakiri = 30 | |
harakiri-verbose = true | |
limit-post = 65536 | |
post-buffering = 8192 | |
vacuum = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name ilovenatalia.net www.ilovenatalia.net; | |
access_log /var/log/nginx/ilovenatalia.net_access.log; | |
error_log /var/log/nginx/ilovenatalia.net_error.log; | |
if ($http_host != "www.ilovenatalia.net") { | |
rewrite ^ http://www.ilovenatalia.net$request_uri permanent; | |
} | |
location / { | |
uwsgi_pass unix:///run/uwsgi/app/ilovenatalia.net/ilovenatalia.net.socket; | |
include uwsgi_params; | |
uwsgi_param UWSGI_SCHEME $scheme; | |
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; | |
} | |
location /media/ { | |
alias /opt/django_apps/ilovenatalia/ilovenatalia/media/; | |
expires 14d; | |
} | |
location /static/ { | |
alias /opt/django_apps/ilovenatalia/ilovenatalia/static/; | |
expires 14d; | |
} | |
location /robots.txt { | |
alias /opt/django_apps/ilovenatalia/ilovenatalia/static/robots.txt; | |
log_not_found off; | |
access_log off; | |
allow all; | |
} | |
location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ { | |
expires 14d; | |
log_not_found off; | |
} | |
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). | |
location ~ /\. { | |
deny all; | |
access_log off; | |
log_not_found off; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /opt/django_apps/ilovenatalia/ilovenatalia/uwsgi.py | |
import os | |
import sys | |
SITE_DIR = '/opt/django_apps/ilovenatalia' | |
sys.path.append(SITE_DIR) | |
sys.path.append('/opt/django_apps/ilovenatalia/ilovenatalia') | |
sys.path.append('/home/kcoyner/.virtualenvs/ilovenatalia') | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ilovenatalia.settings") | |
# This application object is used by any WSGI server configured to use this | |
# file. This includes Django's development server, if the WSGI_APPLICATION | |
# setting points here. | |
from django.core.wsgi import get_wsgi_application | |
application = get_wsgi_application() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment