Nginx+Bottle+uWsgi配置

需求:把一些数据输出并展现到前端,比如曲线变化、数据列表等

工具:后端用python,web框架用bottle,前端用Query Mobile

本文主要记录部署过程:

1、安装并配置好Nginx;

绑定域名需配置Nginx,只需要在server中加入

location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8080;
}

其他,如同Nginx的配置。

2、安装并配置uWsgi;

安装方式:pip install uwsgi

使用方式:

进入bottle 代码目录,添加:

from bottle import default_app

然后启动,不使用run(),添加:

application = default_app()

然后开启uwsgi:

uwsgi -s 127.0.0.1:8080 -w index

index  是bottle的文件名。

启动是在bottle当前目录,并且要把bottle.py放在这里。

wget https://github.com/defnull/bottle/raw/master/bottle.py

把uwsgi放在后台运行并记录日志,使用:

uwsgi -s 127.0.0.1:8080 -w index --daemonize /var/log/uwsgi.log

daemonize的使用前面是加双横杠,网上搜了一堆居然都是单横杠,怎么也无法成功。

以上配置足以使web跑起来,配置完毕。

———————————————

学习教程:

Query Mobile     http://www.w3school.com.cn/jquerymobile/

Bottle                   http://www.bottlepy.org/docs/dev/index.html

转载随意~:陶醉seo » Nginx+Bottle+uWsgi配置

赞 (118)
分享到:更多 ()