日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

nginx连接uwsgi使用web.py框架构造pythonweb项目

發布時間:2023/12/9 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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项目的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。