uwsgi基础——快速入门

原文:http://projects.unbit.it/uwsgi/wiki/Quickstart

快速开始

以下教程是官方版本,如果你使用的debian的包(完全模块化),你需要添加http和python模块。

uWSGI-http+WSGI app

现在来一个简单的例子:

( /var/www/hello.py )

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return "Hello World"


安装 uWSGI

pip install uwsgi

运行http请求: 9090

uwsgi --http :9090 --wsgi-file /var/www/hello.py

在浏览器里输入 localhost:9090

uWSGI-http+Django

Install uWSGI (如果没安装的话)

pip install uwsgi

使用ini配置文件配置django的端口到8000(可以叫django.ini)

项目目录 /var/www/myapp

django 版本>=1.4 ,使用这个文件(将myapp换成你的项目名字):

[uwsgi]
# set the http port
http = :8000
# change to django project directory
chdir = /var/www/myapp
# load django
module = myapp.wsgi

django之前的版本用下面的配置:

[uwsgi]
# set the http port
http = :8000
# change to django project directory
chdir = /var/www/myapp
# add /var/www to the pythonpath, in this way we can use the project.app format
pythonpath = /var/www
# set the project settings name
env = DJANGO_SETTINGS_MODULE=myapp.settings
# load django
module = django.core.handlers.wsgi:WSGIHandler()


运行

uwsgi --ini django.ini

浏览器里访问8000端口就能访问你的应用了。

Nginx+uWSGI+flask

没用这个,不看

Apache2+uWSGI+multiple flask apps


没用这个,不看

posted on 2012-11-26 14:28  DON'T PANIC  阅读(1408)  评论(0)    收藏  举报

导航