Back

LNMP搭建Web.py环境

|

测试环境:ubuntu 10.04LTS + Python 2.6.5 + 军哥[lnmp](http://www.lnmp.org "LNMP一键包")一键包

【编译安装uwsgi(我也不知道为啥要用这个,但是据说这个性能很牛逼。】
[cc]apt-get install python2.6-dev
wget http://projects.unbit.it/downloads/uwsgi-0.9.7.1.tar.gz
tar xzvf uwsgi-0.9.7.1.tar.gz
cd uwsgi-0.9.7.1
make -f Makefile.Py26
cp uwsgi /usr/local/nginx/[/cc]

【安装webpy】
[cc]apt-get install python-pip
pip install web.py[/cc]

【Nginx vhost配置】
[cc]server
{
listen 80;
server\_name iloveq.org www.iloveq.org; #测试域名
location /{
root /home/wwwroot/iloveq.org;
uwsgi\_pass 127.0.0.1:9001;
include uwsgi\_params;
index index.html index.htm;
}
access\_log /home/wwwlogs/iloveq.log;
}[/cc]
【index.py页面代码】
[cc lang="python"]import web
urls = (
'/', 'index'
)
class index:
def GET(self):
return "Hello, world!"
app = web.application(urls, locals())
application = app.wsgifunc() [/cc]
[cc]mv ./index.py /home/wwwroot/iloveq.org[/cc]
执行uWSGI:
[cc]/usr/local/nginx/uwsgi -s 127.0.0.1:9001 -w index[/cc]

访问http://iloveq.org/看是否能输出Hello World!

No comments yet

Leave a comment

About me

I live in Tasmania, an island a little far from the rest of the world and very close to the sea.
Father of two little girls, have two puppies.

Work

Work in IT industry, AI is my working partner.