gunicorn+anaconda+nginx部署django项目(ubuntu)
首先进入conda 虚拟环境:
source activate test
安装gunicorn:
pip install gunicorn
运行gunicorn
gunicorn -w 2 -b 127.0.0.1:9200 -D test.wsgi:application # -D 为后台运行
或者配置gunicorn.py 文件,并放置在项目根目录下:
from gevent import monkey
monkey.patch_all()
import multiprocessing
debug = True
loglevel = 'debug'
bind = '127.0.0.1:9200' //绑定与Nginx通信的端口
pidfile = 'log/gunicorn.pid'
logfile = 'log/debug.log'
workers = multiprocessing.cpu_count() * +
worker_class = 'gevent' //默认为阻塞模式,最好选择gevent模式
并运行 gunicorn -c gunicorn.py test.wsgi:application -D
这时可以用ps -ef | grep gunicorn 命令看gunicorn是否运行
接下来配置nginx:
在配置nginx前,先要在django setting 文件中host中加上localhost,否则会报400错误。并重启gunicorn, kill -HUP pid (ps -ef | grep gunicorn 查看pid)
首先安装nginx, 运行命令 sudo apt install nginx
nginx 命令:
sudo service nginx start 启动
sudo service nginx stop 停止
sudo service nginx restart 关闭
配置文件:
sudo vim /etc/nginx/site-available/test.conf
server {
listen ;
charset utf-;
client_max_body_size 75M;
location / {
proxy_pass http://127.0.0.1:9200;
}
}
并生成软链接 sudo ln -s /etc/nginx/site-available/test.conf /etc/nginx/site-enabled/test.conf
重启nginx, sudo service nginx restart
gunicorn+anaconda+nginx部署django项目(ubuntu)的更多相关文章
- uwsgi+anaconda+nginx部署django项目(ubuntu下)
conda 环境不必多说: conda(或source) activate test 进入test虚拟环境 接下来安装uwsgi: pip install uwsgi 在conda环境下大概率安装 ...
- 使用uWSGI+nginx部署Django项目
最近使用django写了一些项目,不过部署到服务器上碰到一些问题,还有静态文件什么的一堆问题,这里总结一下碰到的问题和解决方案,总体思路是按照官方文档走的. 原文地址:http://uwsgi-doc ...
- ubuntu18+uwsgi+nginx部署django项目
更新系统软件源 sudo apt-get update pip3安装 sudo apt install python3-pip 安装virtualenvwrapper pip3 install vir ...
- Ubuntu+Django+uWSGI+Nginx部署Django项目
安装uWSGI,pip依据自己要使用的python版本自行选择,python2.x版本使用pip进行安装,python3.x版本使用pip3进行安装 pip install uwsgi 配置uWSGI ...
- 阿里云轻量级服务器和NGINX部署Django项目
部署条件: 1.一台阿里云服务器(本人的是CentOS系统的服务器) 2.已经构建好的项目 3.服务器上安装并配置Nginx 首先第一步:在服务器上安装并配置Nginx 进入服务器 $ ssh roo ...
- uwsgi+nginx部署django项目
1. 概念解析(wsgi协议,uwsgi协议,uWSGI) 参考:https://www.cnblogs.com/wspblog/p/8575101.html 1.1 现实世界的web请求: 1.2 ...
- 关于Nginx部署Django项目的资料收集
参考:https://www.cnblogs.com/chenice/p/6921727.html 参考:https://blog.csdn.net/fengzq15/article/details/ ...
- Python项目部署-使用Nginx部署Django项目
一.nginx介绍及部署 二.nginx部署路飞学城代码 nginx配置安装 同样,nginx也有很多的安装方式: 1)源码安装(运维偏向:规范,便于配置管理) 2)yum,rpm安装(为了效率可以选 ...
- 在centos8使用Docker部署Django项目
引言 在本文中将介绍在Docker中通过django + uwsgi + nginx部署方式部署Django项目, 由于记录的是学习过程,使用的都是目前较高的版本. python 版本为3.8.3 d ...
随机推荐
- IntelliJ IDEA 最新激活码
C40PF37RR0-eyJsaWNlbnNlSWQiOiJDNDBQRjM3UlIwIiwibGljZW5zZWVOYW1lIjoiemhhbmcgeW9uZyIsImFzc2lnbmVlTmFtZ ...
- linux系统ubuntu18.04安装mysql(5.7)
本文是参考mysql官网整理而成,顺便把一些遇到的问题记载下来. ①将MySQLAPT存储库添加到系统的软件存储库列表中 ---->下载APT存储库(下载链接) ---->安装APT存 ...
- 使用axios 的post请求下载文件,
axios({ method: 'post', data: param, responseType:'blob', url: _urls + '/Downloaddata' }).then(data= ...
- Linux系统下Mysql安装与配置
一,使用系统 Centos7: 在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB. 二,下载安装 ...
- Linux操作系统计划任务
++++++++++++++++++++++++++++++++++++++++++++++++标题:Linux操作系统的计划任务内容:计划任务分为单次任务和周期性任务,周期任务分为系统级计划任务和用 ...
- OSI七层模型的每一层都有哪些协议
TCP/IP: 数据链路层:ARP,RARP 网络层: IP,ICMP,IGMP 传输层:TCP ,UDP,UGP 应用层:Telnet,FTP,SMTP,SNMP. OSI: 物理层:EIA/TIA ...
- 数据转换失败 java.math.BigDecimal cannot be cast to java.lang.String
从接口获取到数据,在转换的时候出现错误:java.math.BigDecimal cannot be cast to java.lang.String 因为一开始用的是使用关键字进行强制转换,后来发现 ...
- NodeJs之服务搭建与数据库连接
NodeJs之服务搭建与数据库连接 一,介绍与需求分析 1.1,介绍 Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境. Node.js 使用了一个事件驱动.非阻 ...
- codeforces463D
Gargari and Permutations CodeForces - 463D Gargari got bored to play with the bishops and now, after ...
- Codeforces #402
目录 Codeforces #402 Codeforces #402 Codeforces 779A Pupils Redistribution 链接:http://codeforces.com/co ...