lap00 2014-01-19
初次部署Django project in ubuntu server
Init env:
python -V 2.7.3
Django 1.6
Linux ubuntu
Steps:
upstream demos { server 127.0.0.1:9090 fail_timeout=0; #server unix:/var/www/demos/run/gunicorn.sock } server { listen 8000; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /var/www/demos; server xxxx.com; location / { proxy_pass http://demos; } location /static { ..... } error_page 404 500 504 /404.html; location = /404.html { root html; } }
测试页面 http://127.0.0.0:8000 ,see "Congratulations on your first Django-powered page." successfully
#!/bin/bash name="demos" project_dir=/var/www/demos sockfile=/var/www/demos/run/gunicorn.sock address=0.0.0.0 port=9090 num_wks=3 dj_setting_module=demos.settings dj_wsgi_module=demos.wsgi echo "Starting $name as `whoami`" rundir=$(dirname $sockfile) test -d $rundir || mkdir -p $rundir exec gunicorn ${dj_wsgi_module}:application \ --workers $num_wks \ --log-level=debug \ --bind=$address:$port #--bind=unix:$sockfile
[program:demos] command = /var/www/demos/run/runserver.sh stdout_logfile = /var/www/demos/logs/gunicorn_supervisor.log redirect_stderr = true
Refs:
http://ijcdigital.com/blog/django-gunicorn-and-nginx-setup
http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
username=user ; should be same as http_username if set. password=123 ; should be same as http_passwo