使用gunicorn 部署django项目 1 安装python-pipapt-get install python-pip2 安装gunicornpip install gunicorn3 安装djangopip install django==1.94 进入到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.keyopenssl req -new -x509 -nodes -sha1 -days 365 -key stunnel.key > stunnel.certgunicorn -w3 --certfile=stunnel.cert --keyfile=stunnel.key --bind=0.0.0.0:80 adminweb.wsgi:application 来自 大脸猫 写于 2016-08-13 18:53 -- 更新于2020-10-19 13:06 -- 0 条评论