Created
September 3, 2014 21:22
-
-
Save mtkp/fd94d39aa33ecc0e2dda to your computer and use it in GitHub Desktop.
Simple configuration: Django + Nginx + Gunicorn
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
# /etc/gunicorn.d/gunicorn-proj | |
CONFIG = { | |
'mode': 'django', | |
'user': 'myuser', | |
'group': 'myuser', | |
'working_dir': '/path/to/django/proj', | |
'environment': { | |
'PYTHONPATH': '/path/to/django/proj' | |
}, | |
'args': ( | |
'--bind=127.0.0.1:8040', | |
'--workers=3', | |
'conf.settings', | |
), | |
} |
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
# /etc/nginx/sites-available/nginx-proj | |
upstream app_server { | |
server 127.0.0.1:8040; | |
} | |
server { | |
listen my.ip.or.dns:80; | |
location /static/ { | |
alias /path/to/static/; | |
} | |
location / { | |
proxy_pass http://127.0.0.1:8040; | |
proxy_pass_request_headers on; | |
} | |
} |
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
# /path/to/django/proj/conf/settings.py | |
# Django project settings file (moved into a separate directory, `conf`) | |
# ... | |
ALLOWED_HOSTS = ['127.0.0.1'] | |
STATIC_ROOT = '/path/to/static/' | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple configuration to get started with Nginx, Gunicorn, and Django.
After installing Nginx and Gunicorn (through
apt-get
), and setting up the above configurations, you can start the web server with: