python bottle部署g_python web(bottle框架)之环境搭建
有任何疑问欢迎QQ交流:2691216015
1. 首先弄懂下面几个东西的含义:
wsgi
uwsgi
gunicorn
supervisor
nginx
2.web之环境搭建
1) 创建虚拟环境:
virtualenv shan_env
source shan_env/bin/activate
2) 安装python 相关:
pip install -U bottle
pip install gevent
pip install gunicorn
3) index.py
from bottle import Bottle, run
app = Bottle()
@app.route('/')
@app.route('/hello')
def hello():
return "hello world"
@app.route('/login')
def login():
return "hello login"
#run(app, host='0.0.0.0', port=5003, debug=True)
4) 配置gunicorn:
# gunicorn.conf
# 并行工作进程数
workers = 4
# 指定每个工作者的线程数
threads = 2
# 监听内网端口5000
bind = '0.0.0.0:5003'
# 设置守护进程,将进程交给supervisor管理
daemon = 'false'
# 工作模式协程
worker_class = 'gevent'
# 设置最大并发量
worker_connections = 2000
# 设置进程文件目录
pidfile = '/var/run/gunicorn.pid'
# 设置访问日志和错误信息日志路径
accesslog = '/var/log/gunicorn_acess.log'
errorlog = '/var/log/gunicorn_error.log'
# 设置日志记录水平
loglevel = 'warning'
5) 通过gunicron启动web:
/home/user.dan/www/project_shan/shan_env/bin/gunicorn -c gunicorn.conf index:app
6)nginx 配置nginx.conf:
server {
listen 80;
root /home/user.dan/www/project_shan;
server_name shan.com;
access_log /home/user.dan/logs/access.log;
error_log /home/user.dan/logs/error.log;
location / {
proxy_pass http://127.0.0.1:5003;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
7)supervisor使用进程管理:
/etc/supervisor/conf.d/shan.ini
[program:shan]
command=/home/user.dan/www/project_shan/shan_env/bin/gunicorn -c gunicorn.conf index:app
directory=/home/user.dan/www/project_shan
autostart=true
environment=LANG="en_US.utf8", LC_ALL="en_US.UTF-8", LC_LANG="en_US.UTF-8"
/usr/bin/python2.7 ./supervisord
supervisorctl status
supervisorctl stop shan
supervisorctl update
#更新新的配置到supervisord
supervisorctl update
#重新启动配置中的所有程序
supervisorctl reload
#启动某个进程(program_name=你配置中写的程序名称)
supervisorctl start program_name
有任何疑问欢迎QQ交流:2691216015
python bottle部署g_python web(bottle框架)之环境搭建相关推荐
- Selenium基于Python的web自动化测试框架(1)-环境搭建
环境搭建 前言 一.selenium简介 二.环境搭建 1. 笔者环境 2. Python安装 三. 验证安装是否成功 1. 打开win 命令行界面 2. 输入 python 回车,如果出现一下界面, ...
- (三)Linux环境部署(Centos+Nginx+Tomcat+Mysql) - Nginx环境搭建
因为在网上发现系统性.严谨(特别是在安全方面)的Linux部署方面的参考文章很少,于是整理以下六篇Linux环境部署的系列性文章,其为本人在实践中,完整的搭建一个基于Linux系统上Centos+Ng ...
- Web笔记(一) Web 简介与开发环境搭建
Web应用程序的工作原理 大多数的Web应用程序结构都是采用最为流行的B/S软件开发体系结构,将Web应用程序部署在Web服务器上,只要Web服务器启动,用户就可以通过客户端浏览器发送HTTP请求到W ...
- Mybatis入门:1(Mybatis框架的环境搭建)
Mybatis框架的环境搭建 一.创建maven工程并导入坐标 导入坐标: <dependencies><dependency><groupId>org.mybat ...
- linux下nginx+python+fastcgi部署总结(web.py版)
2019独角兽企业重金招聘Python工程师标准>>> 在上一篇文章linux下nginx+python+fastcgi部署总结(django版)中,我们部署了nginx+djang ...
- struts2 web应用框架的简单搭建步骤
Struts2 Struts2的工作流程: 在Struts2视图层,获取数据,交给action处理,再返回到视图层. 一.什么是Strues2 Struts2是一个基于MVC设计模式的Web应用框架, ...
- python项目部署失败的原因_python项目环境部署(一)
postman:进行rest请求方式测试 nginx,supervisor,uwsgi/gunicorn 1.系统依赖包管理 https://github.com/bndr/preqs ubuntu命 ...
- python bootstrap安装_python + django + bootstrap + uWSGI + nginx 环境搭建
在了解 uWSGI 之前,我们不妨先了解一下 python http服务器? 要使 Python 写的程序能在 Web 上被访问,还需要搭建一个支持 Python 的 HTTP 服务器,列举几个如 G ...
- SSH框架总结(框架分析+环境搭建+实例源代码下载)
首先,SSH不是一个框架,而是多个框架(struts+spring+hibernate)的集成,是眼下较流行的一种Web应用程序开源集成框架,用于构建灵活.易于扩展的多层Web应用程序. 集成SSH框 ...
最新文章
- 福利直投!这个活动承包你2020全年技术干货
- (深入理解)matplotlib的交互模式(block,interactive,ion,ioff,draw,show,plot等的区别)
- Vmware 10 安装
- 基于Grafana的Repeate Panel快速定义面板
- 【无私分享:从入门到精通ASP.NET MVC】从0开始,一起搭框架、做项目(5.5) 登录功能的实现,完善登录功能...
- CTU——一个神奇的oj
- matlab全景图素材,科学网—meshlab查看360度全景图像 - 王琳的博文
- 云更新可以装在个人计算机上吗,云更新服务器安装
- Linux环境下编写C程序
- Android CheckBox 实战
- C#创建单链表,翻转单链表
- 产品经理常用专业名词
- Spark SQL 之开窗函数
- IT给生活带来了什么?
- 免费的HTTP代理IP服务器地址
- Ubuntu下查看文件、文件夹和磁盘空间的大小
- lambda表达式与正则表达式
- 谁会成为印度版微信?
- 【php】php开发的前期准备
- 解决 HTML div css 强制 换行 不换行