nginx连接uwsgi使用web.py框架构造pythonweb项目
2019独角兽企业重金招聘Python工程师标准>>>
相关页面:
http://webpy.org/install
http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html
http://projects.unbit.it/uwsgi/wiki/Example
uwsgi的安装需要python-devel,可以使用yum search python-devel进行查找
没有的话可以到
http://www.rpmfind.net/进行相关rpm包进行查找
uwsgi安装:
wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz
tar zxvf uwsgi-latest.tar.gz
cd <dir>
make
生成可执行的二进制文件uwsgi
文件位置:
mkdir /home/uwsgi
mv uwsgi /home/uwsgi/
web.py安装:
http://webpy.org/install
python setup.py install 在解压的tar包中进行安装
简单运行文件:
vim test.py :
/usr/bin/python
import web
urls=('/(.*)','hello')
app=web.application(urls,globals())
class hello:def GET(self,name):if not name:name='World'return 'Hello'+name+'!'
application=app.wsgifunc()
uwsgi启动方式:
/home/uwsgi/uwsgi --socket 127.0.0.1:9000 --chdir /home/project/maintence.xxx.xxx.com/ -w test
/home/project/maintence.xxx.xxx.com/目录为test.py所在目录
nginx配置:
server {
listen 80;
server_name maintence.xxx.xxx.com;
access_log logs/access_maintence.xxx.xxx.com.log main;
error_log logs/error_maintence.xxx.xxx.com.log warn;
root /home/nginx/html/maintence.xxx.xxx.com;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9000;
}
}
以上配置可以完成nginx-uwsgi的直连,使用web.py框架
uwsgi可以使用配置文件的方式进行配置:
<whousexml>
<uwsgi id='e-commerce'>
<socket>127.0.0.1:9000</socket>
<chdir>%d/../src</chdir>
<module>test</module>
<master />
<workers>4</workers>
<cpu-affinity>2</cpu-affinity>
<daemonize>%d/../log/uwsgi.log</daemonize>
<pidfile>%d/../log/uwsgi.pid</pidfile>
</uwsgi>
</whousexml>
启动方式:
uwsgi_home='/home/uwsgi'
service_home='/home/project/maintencexxx.xxx.com'
service_id='xxx'
$uwsgi_home/uwsgi --xml $service_home/conf/uwsgi.conf:$service_id
停止:
$uwsgi_home/uwsgi --stop $pid_file
reload:
$uwsgi_home/uwsgi --reload $pid_file
一个简单的启动脚本:
if [ `whoami` != appuser ]
thenecho 'This script need appuser user'exit 1
fi
if [ $# -ne 1 ]; thenecho "Usage:$0 {stop|start|restart|reload}"exit -1
fi
uwsgi_home='/home/uwsgi'
service_home='/home/project/maintence.xxx.xxx.com'
service_id='xxx'
pid_file=$service_home/log/uwsgi.pid
pid=$(cat $pid_file)function start(){$uwsgi_home/uwsgi --xml $service_home/conf/uwsgi.conf:$service_id
}
function stop(){$uwsgi_home/uwsgi --stop $pid_filesleep 3( netstat -tlunp | grep $pid | grep -q uwsgis ) 2> /dev/nullif [ $? == 0 ];thenkill -9 $pidsleep 1fi
}
function reload(){$uwsgi_home/uwsgi --reload $pid_file
}case $1 in stop)stop;;start)start;;restart)stopstart;;reload)reload;;
esac
转载于:https://my.oschina.net/u/273053/blog/130149
nginx连接uwsgi使用web.py框架构造pythonweb项目相关推荐
- win8下Python学习——搭建web.py框架
1.安装python2.7.3 ,下载 2.添加环境变量,如下图 3.安装web.py,下载 解压web.py的安装包,如下 进入cmd,运行以下命令,web.py框架就安装好了 4.测试一下web. ...
- python web.py框架 无法正常打开0.0.0.0:8080网页
最近意外用到了web.py框架,才发现这家伙比Django还轻量,还简洁.但是开局就碰到了问题. import weburls = ('/(.*)', 'hello' ) app = web.appl ...
- 基于nginx和uWSGI在Ubuntu系统上部署Django项目
1. nginx 1.1 安装 sudo apt-get install nginx 1.2启动.停止和重启 sudo /etc/init.d/nginx start sudo /etc/init.d ...
- web.py框架入门
在使用微信搭建公众平台的时候,使用的是web.py这个方便简单的框架,学习一下. 框架文档:http://webpy.org/docs/0.3/tutorial.zh-cn 按照文档的内容写一遍程序 ...
- docker-compose:使用docker-compose部署nginx+supervisor+uwsgi+flask程序(mongodb)
0 写在前面 百度搜索的文档渣的要命,一定要Google,一定要GitHub. 1 目录层次 我们必须清楚我们docker-compose.yaml文件和Dockerfile的位置以及其他配置脚本的位 ...
- python 实现网站_python 实现网站_用web.py实现python网站版hello world网页
github源码安装 浏览器打开https://github.com/webpy/webpy,下载源码zip格式,解压出来.cmd打开,cd到解压目录,输入 python setup.py insta ...
- Python 3.x 安装 web.py ,血泪!!
Python3.x 安装 web.py ,血泪!! 简述 适用平台 Linux 安装 安装结果 Windows 安装 测试 批注 简述 更新时间:2019-7-14 内容:以前没有发现window p ...
- python websocket异步高并发_高并发异步uwsgi+web.py+gevent
为什么用web.py? python的web框架有很多,比如webpy.flask.bottle等,但是为什么我们选了webpy呢?想了好久,未果,硬要给解释,我想可能原因有两个:第一个是兄弟项目组用 ...
- 高并发异步uwsgi+web.py+gevent
为什么用web.py? python的web框架有很多,比如webpy.flask.bottle等,但是为什么我们选了webpy呢?想了好久,未果,硬要给解释,我想可能原因有两个:第一个是兄弟项目组用 ...
最新文章
- 什么是OKR?目标管理如何做?
- Storm入门(九)Storm常见模式之流聚合
- Hive到SparkSql
- leetcode-125-Valid Palindrome
- linux查看修改环境变量日志,linux查看和修改PATH环境变量的方法
- linux数据包注释,关于 linux中TCP数据包(SKB)序列号的小笔记
- 【C++ Primer | 13】课后习题答案
- C/C++蓝桥杯1 备赛准备
- bzoj 1663: [Usaco2006 Open]赶集(最长路)
- vscode插件之Vetur
- 在html标签中写css样式,html style样式标签元素教程
- python职业发展规划-少走弯路,一个老程序猿谈PHP职业发展规划
- 【评分】软件工程实践2017第一次作业-准备
- xp升级到win7傻瓜教程_MeGUI教程-软件环境配置(转)
- 针对豆瓣TOP250电影知识图谱的构建(Python+neo4j)
- C++解压zip压缩文件
- linux下的etc文件夹
- day14_html和css
- ctfshow F5杯 部分WP(writeup) 超详细
- Android-live如何利用第三方SDK做一款直播软件