Python 部署 flask 用uwsgi和nginx
2024-09-03 05:57:48
安装uwsgi nginx 具体方法请百度
1.在项目目录下建立.ini文件
xad_uwsgi.ini
[uwsgi]
master=true
#项目目录
chdir=/root/zhaoyingjie/xadconf
#虚拟环境
virtualenv=/root/zhaoyingjie/pyenv/xadconf
#module=xadserver
#plugins=python
#所需要运行的文件
mount=/=main.py
manage-script-name=true
# TODO
py-autoreload=0
lazy-apps=true
callable=app
#与nginx通信的接口
socket=127.0.0.1:5012 # TODO
#master = true
#所起几个进程
processes=8
#确保文件路径存在 存主进程号
pidfile = /root/zhaoyingjie/xadconf/xadserver_uwsgi.pid
#threads = 2 # threads=2
buffer-size=32768 #确保路径文件在
daemonize = /root/zhaoyingjie/xadconf/uwsgi.log
log-maxsize = 1000000
log-truncate = true
disable-logging = true
2配置nginx文件
在此路径下建立对应文件如果没有请自行创建 xadconf.test.com为二级域名
/etc/nginx/sites-enabled/xadconf.test.com
#xadconf.test.com 内容为
server {
listen 80;
#域名或ip
server_name xadconf.test.com;
#存放log的相对路径
root /data2/output/;
autoindex on;
location /xad_debug {
return 404;
}
location /xad_err_request {
return 404;
}
location /favicon.ico {
return 404;
}
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:5012;
}
#存放log路径
access_log /data2/output/logs/xadconf/access.log;
error_log /data2/output/logs/xadconf/error.log;
disable_symlinks off;
charset utf-8;
}
3.在完成上面配置后,需要按以下步骤来做:重启Nginx服务器,以使Nginx的配置生效。
nginx -s reload
4.回到项目跟目录启动uwsgi
uwsgi -i XX.ini
5. ps aux | grep uwsgi 检查uwsgi的进程
6.kill -9 进程号 杀死 uwsgi的进程
最新文章
- Cesium应用篇:3控件(2)BaseLayerPicker
- javascript 伪协议
- What is the difference between provider network and self-service network in OpenStack?
- Struts1 标签库 说明
- 判断浏览器是IE的几种方式
- Server-U与IIS端口占用问题解决
- find &; rm
- my_vimrc
- Android在ListView滑动数据混乱
- 求解释一个蛋疼的bug
- group by 多字段分组
- SmartAdmin(SmartAdmin_v1.5.2)
- C++ 变量的引用 &;
- dubbo的本地存根(Stub)
- 微软Office Online服务安装部署(二)
- 011 Spark应用构成结构
- angular的组件通信
- 20155312 2016-2017-2 《Java程序设计》第十周学习总结
- SQLServer 学习笔记之超详细基础SQL语句 Part 5
- HihoCoder - 1886 :中位数2(贪心)