1 安装python-pip
apt-get install python-pip
2 安装gunicorn
pip install gunicorn
3 安装django
pip install django==1.9
4 进入到app目录
nohup gunicorn --bind=0.0.0.0:8000 -u www-data -g www-data dazhu.wsgi:application &
5 如果static不能访问
在开发环境,可以在urls.py添加
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# ... the rest of your URLconf goes here ...
urlpatterns += staticfiles_urlpatterns()
在线上环境,应该使用nginx进行代理
location /static {
autoindex on;
alias /home/yzh/workspace/dazhu0804/dazhu/static;
}
6 使用证书
openssl genrsa 1024 > stunnel.key
openssl req -new -x509 -nodes -sha1 -days 365 -key stunnel.key > stunnel.cert
gunicorn -w3 --certfile=stunnel.cert --keyfile=stunnel.key --bind=0.0.0.0:80 adminweb.wsgi:application