Python uWSGI部署服务
什么是uWSGI
uWSGI旨在为部署分布式集群的网络应用开发一套完整的解决方案。主要面向web及其标准服务。由于其可扩展性,能够被无限制的扩展用来支持更多平台和语言。uWSGI是一个web服务器,实现了WSGI协议,uwsgi协议,http协议等。
uWSGI的主要特点是:
- 超快的性能
- 低内存占用
- 多app管理
- 详尽的日志功能
- 高度可定制
uWSGI服务器自己实现了基于uwsgi协议的server部分,我们只需要在uwsgi的配置文件中指定application的地址,uWSGI就能直接和应用框架中的WSGI application通信
安装uWSGI
pip install uwsgi
uWSGI配置文件
这里给个样例作为参考
[uwsgi]
# 指向项目目录
chdir = /XXX/XXX/XXXX# 外部访问地址,主要是指定端口号。可以指定多种协议:http 或 socket
socket = 127.0.0.1:8888
# http = 127.0.0.1:8888# flask启动程序文件
wsgi-file = XXX.py# flask在manage.py文件中的app名
callable = app# 处理器数
processes = 4# 存储日志信息
logto = /XXX/XXX/XXX.log# 线程数
threads = 8# 设置uwsgi的pid文件
pidfile = /XXX/XXX.pid# 设置uwsgi的status文件
statusfile = /XXX/XXX.status
Nginx反向代理配置文件
这里给个样例作为参考
# the upstream component nginx needs to connect to
upstream XXX {server 127.0.0.1:7777;
}# configuration of the server
server {# the port your site will be served onlisten 1002;# the domain name it will serve for#server_name .example.com; # substitute your machine's IP address or FQDNserver_name XXXX;charset utf-8;# Finally, send all non-media requests to the Django server.location / {uwsgi_pass XXX;include uwsgi_params; # the uwsgi_params file you installed}
}
PS. 对于新建的配置文件,需要在nginx.conf里面加入引入路径:include vhosts/*.conf
user work;
worker_processes auto;#error_log logs/error.log;
error_log /data/logs/nginx/host/logs/host_error.log notice;
#error_log logs/error.log info;pid logs/nginx.pid;events {use epoll;accept_mutex off;worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent $request_body "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for" "$request_time"';access_log /data/logs/nginx/host/logs/host_access.log main;server_tokens off;sendfile on;#tcp_nopush on;tcp_nodelay on;#keepalive_timeout 0;keepalive_timeout 65;client_header_buffer_size 4k;client_max_body_size 20M;open_file_cache max=102400 inactive=30s;open_file_cache_valid 30s;open_file_cache_min_uses 0;gzip on;gzip_min_length 1k;gzip_buffers 4 8k;gzip_http_version 1.1;gzip_comp_level 6;gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/javascript application/json;include vhosts/*.conf;
}
常见的命令
- 启动uwsgi服务
uwsgi --ini uwsgi.ini
- 查看uwsgi的pid号
cat uwsgi/uwsgi.pid
- 查看一下uwsgi的进程
ps aux | grep uwsgi
- 重启uwsgi
uwsgi --reload uwsgi/uwsgi.pid
- 停止uwsgi
uwsgi --stop uwsgi/uwsgi.pid
- 查看uwsgi的版本
uwsgi --version
- 测试配置文件是否有语法错误
nginx -t
- 重启Nginx
nginx -s reload
- 测试配置文件是否有语法错误
nginx -t
- 强制停止Nginx服务
nginx -s stop
Python uWSGI部署服务相关推荐
- linux部署python web项目 详细_linux下nginx+python+uwsgi部署总结(django+web.py)
ara on 2011年10月24日 17:23 # 按您文章进行了配置,出现错误,请教问题原因 nginx.conf 配置: server { # python/uwsgi listen 80; r ...
- python nginx部署_Python 应用 uWSGI + Nginx 部署
新建一个 Django 应用部署 •使用 py 文件启动 uWSGI def application(env, start_response):start_response('200 ok', [(' ...
- python uwsgi+nginx部署
typora-root-url: ./ 项目环境部署 一.MySQL5.7安装 1.安装方式 1.1 方式一 yum安装(推荐使用该方式) 在CentOS中默认安装有MariaDB,这个是MySQL的 ...
- centos部署python flask_python 微服务框架之nameko实践
大纲: 1.本篇关键技术点及其释义 2.实际需求和目标 3.可行的三大解决方案 4.微服务与传统服务的差别 5.代码大纲:安装依赖及nameko五个完整的代码示例 6.附录:docker的在线安装方式 ...
- python uwsgi_Python Web 程序使用 uWSGI 部署
Python Web 程序使用 uWSGI 部署 WSGI是什么? WSGI,全称 Web Server Gateway Interface,或者 Python Web Server Gateway ...
- [附源码]计算机毕业设计Python+uniapp家政服务系统小程序7na26(程序+lw+远程部署)
[附源码]计算机毕业设计Python+uniapp家政服务系统小程序7na26(程序+lw+远程部署) 该项目含有源码.文档.程序.数据库.配套开发软件.软件安装教程 项目运行环境配置: Python ...
- python脚本部署为Windows服务
python脚本部署为Windows服务 基础需求环境:python环境(不会安装建议ctrl+w, 你已经退出接下来的教程了)windows环境(需要了解环境变量的配置和服务位置) 好了,开始吧. ...
- 【转】Nginx+uWSGI 部署 Django 应用
原文来自: http://www.oschina.net/question/54100_30386 http://obmem.info/?p=703 常见的django webapp 部署方式采用FC ...
- python与rpc服务
什么是rpc 随着企业 IT 服务的不断发展,单台服务器逐渐无法承受用户日益增长的请求压力时,就需要多台服务器联合起来构成「服务集群」共同对外提供服务. 同时业务服务会随着产品需求的增多越来越肿,架构 ...
最新文章
- 第一周Access课总结
- 现有模型还「不懂」自然语言:20多位研究者谈NLP四大开放性问题
- redis启动问题:/var/redis/run/redis_6379.pid exists, process is already running or crashed
- Python中str、list、numpy分片操作
- 【原创】android——SQLite的cmd命令的基本操作
- pyqt5讲解8:容器QTabWidget,QStackedWidget,QDockWidget
- echart 坐标数字间隔_用LaTeX优雅地绘制数字电路
- C#正则表达式判断输入日期格式是否正确
- (王道408考研操作系统)第二章进程管理-第一节3:进程控制(配合Linux讲解)
- 将Visual Studio Code和Windows Subsystem for Linux一起使用
- cas客户端登陆状态不同步_Java并发——同步组件
- 能源36号文解读_电机暴露细节!春风发布新能源品牌:ZEEHO极核
- 201542010208、201571030331软件工程结对项目
- 笔记·模拟电子技术基础——郑益慧老师
- SQL Server Case表达式
- SV绿皮书笔记(八)
- 【自监督论文阅读笔记】Green Hierarchical Vision Transformer for Masked Image Modeling
- Bzoj3236:[Ahoi2013]作业:莫队算法+树状数组
- 图形渲染与UWA论坛,mipi官网
- 买外链有没有影响?会导致网站降权吗?玉米社
热门文章
- [20][03][23] Cookie Security: Over Broad Path
- 居然得了“坐板疮”...
- 管理RMAN备份_报告(Reporting)RMAN操作
- ati2avxx恶意代码手工查杀
- 使用百度SDK实现定位功能
- 色彩的数学规则(二)(转)
- Windows端口号设置范围
- ubuntu18.04安装caffe
- Springboot遇到的一些问题
- php pager,Pear::Pager分页类简介_PHP教程