Python uWSGI 安装配置
本文主要介绍如何部署简单的 WSGI 应用和常见的 Web 框架。
以 Ubuntu/Debian 为例,先安装依赖包:
apt-get install build-essential python-dev
Python 安装 uWSGI
1、通过 pip 命令:
pip install uwsgi
2、下载安装脚本:
curl http://uwsgi.it/install | bash -s default /tmp/uwsgi
将 uWSGI 二进制安装到 /tmp/uwsgi ,你可以修改它。
3、源代码安装:
wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz tar zxvf uwsgi-latest.tar.gz cd uwsgi-latest make
安装完成后,在当前目录下,你会获得一个 uwsgi 二进制文件。
第一个 WSGI 应用
让我们从一个简单的 "Hello World" 开始,创建文件 foobar.py,代码如下:
def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return [b"Hello World"]
uWSGI Python 加载器将会搜索的默认函数 application 。
接下来我们启动