|
|
环境:ubuntu10.10 + python2.6
步骤说明:
编译安装nginx:
- apt-get install build-essential
- apt-get build-dep nginx
- wget http://nginx.org/download/nginx-0.9.6.tar.gz and decompress
- ./configure --prefix=/usr/local/nginx --with-http_ssl_module
- make && make install
编译安装uwsgi:
- apt-get install python2.6-dev libxml2-dev
- wget http://projects.unbit.it/downloads/uwsgi-0.9.7.1.tar.gz and decompress
- make -f Makefile.Py26
- cp uwsgi /usr/local/nginx (anywhere you like)
安装webpy:
- apt-get install python-pip
- pip install web.py
nginx配置:
server { listen 8000; server_name somename alias another.alias; error_log logs/test.log; location / { root html; uwsgi_pass 127.0.0.1:9001; include uwsgi_params; index index.html index.htm; } }
测试脚本test.py:
import web urls = ( '/', 'index') class index: def GET(self): return "Hello, world!" app = web.application(urls, locals())application = app.wsgifunc() 将测试脚本放在nginx的webroot下(缺省为html)。进入html目录,运行命令:
/usr/local/nginx/uwsgi -s 127.0.0.1:9001 -w test 访问http://localhost:8000/。
结束。 |
|