Lighttpd通过FastCGI运行web.py程序

web.py是个很小的python框架,特点就是小,连session都没有实现人家就发布了。前几天KungfuRails大会上他们吹牛说Sinatra可以写出世界上最小的Webapp,但是有web.py的化,那个最小至少要加上个“之一”。

Web.py在Lighttpd上通过fastcgi运行的配置,可以在web.py的网站上找到文档:
http://webpy.org/cookbook/fastcgi-lighttpd

实际我用的时候把静态的index.html用作首页,稍改动一下:

server.document-root = "/home/sun/projects/sdostatweb"

server.modules   += ( "mod_fastcgi" )
server.modules   += ( "mod_rewrite" )

server.port = 4000

mimetype.assign = (
    ".html" => "text/html"
)

index-file.names = ( "index.html" )

fastcgi.server = ( "/sdostatweb.py" =>
(( "socket" => "/tmp/fastcgi.socket",
        "bin-path" => "/home/sun/projects/sdostatweb/sdostatweb.py",
        "max-procs" => 5,
        "bin-environment" => (
        "REAL_SCRIPT_NAME" => ""
    ),
        "check-local" => "disable"
    ))
)

url.rewrite-once = (
    "^/$" => "/static/index.html",
    "^/flotr/(.*)$" => "/static/flotr/$1",
    "^/static/(.*)$" => "/static/$1",
    "^/(.*)$" => "/sdostatweb.py/$1",

)

另外用fastcgi的方式使用web.py,需要安装flup。

详细的事,可以看看新浪的Tim Yang的优化:
http://timyang.net/python/python-webpy-lighttpd/

我之前真不敢相信搜狐Mail是跑在web.py上。

This entry was written by Sunng , posted on Monday November 02 2009at 05:11 pm , filed under 手艺 and tagged , , , . Bookmark the permalink . Post a comment below or leave a trackback: Trackback URL.

2 Responses to “Lighttpd通过FastCGI运行web.py程序”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word