前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用gunicorn 部署django项目

使用gunicorn 部署django项目

作者头像
超级大猪
发布2019-11-22 09:42:38
1.2K0
发布2019-11-22 09:42:38
举报
文章被收录于专栏:大猪的笔记大猪的笔记

1 安装python-pip

代码语言:javascript
复制
apt-get install python-pip

2 安装gunicorn

代码语言:javascript
复制
pip install gunicorn

3 安装django

pip install django==1.9

4 进入到app目录

代码语言:javascript
复制
nohup gunicorn  --bind=0.0.0.0:8000 -u www-data -g www-data dazhu.wsgi:application &

5 如果static不能访问

在开发环境,可以在urls.py添加

代码语言:javascript
复制
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# ... the rest of your URLconf goes here ...
urlpatterns += staticfiles_urlpatterns()

在线上环境,应该使用nginx进行代理

代码语言:javascript
复制
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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-08-13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档