在Debian Squeeze中编译uWSGI支持webpy应用
之所有现在想从fastcgi切换到uwsgi, 关键是web.py的fastcgi和scgi协议实现得有问题,scgi对 chunked post支持不了,fastcgi支持不了过大的post
首先安装libxml2-dev和python-dev, 编译uWSGI需要这两个东西
aptitude install libxml2-dev python-dev
获取最后一版本的uWSGI
wget http://projects.unbit.it/downloads/uwsgi-latest.tar.gz
(当前版本是 http://projects.unbit.it/downloads/uwsgi-0.9.6.5.tar.gz)
解压缩就就进去编译
python uwsgiconfig.py –build
修改web.py应用
将支持fastcgi的语句去掉
#web.wsgi.runwsgi = lambda func, addr=(‘/home/carbon/cherokee/fastcgi.python.socket’): web.wsgi.runfcgi(func, addr)
#web.wsgi.runwsgi = lambda func, addr=(’127.0.0.1′, 9527): web.wsgi.runfcgi(func, addr)
并将
app.run()
改成
application = app.wsgifunc()
这跟webpy支持wsgi 以及 Webpy + Apache with mod_wsgi 的写法是一样的
如果不用uWSGI, 应该这么写
app = web.application(urls, globals(), autoreload=False).wsgifunc()
server = web.wsgiserver.CherryPyWSGIServer(
(’0.0.0.0′, 9527), app, server_name=’zhiwei.li’)
server.start()
http://stackoverflow.com/questions/1078599/deploying-a-web-py-application-with-wsgi-several-servers
参考
http://projects.unbit.it/uwsgi/wiki/Install
http://projects.unbit.it/uwsgi/wiki/Example
http://obmem.info/?p=703
强调一点:
application = app.wsgifunc()
不能放到
if __name__ == “__main__”: 里面
必须顶格写
因为
uwsgi.applications dictionary is not defined, trying with the “applications” one…
applications dictionary is not defined, trying with the “application” callable.
否则会报错
wsgi application not found
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。