webpy的LightTPD配置,webpyLightTPD配置,在生产环境下推荐在Lig


在生产环境下推荐在Lighttpd中以FastCGI形式运行webpy,reddit.com使用这种方式处理日Pv量达到百万。

lighttpd的配置文件如下

 server.modules = ("mod_fastcgi", "mod_rewrite") server.document-root = "/path/to/root/"      fastcgi.server = ( "/code.py" =>      (( "socket" => "/tmp/fastcgi.socket",    "bin-path" => "/path/to/root/code.py",    "max-procs" => 1 )) ) url.rewrite-once = (   "^/favicon.ico$" => "/static/favicon.ico",   "^/static/(.*)$" => "/static/$1",   "^/(.*)$" => "/code.py/$1" )

在有些版本的lighttpd中需要确认将fastcgi.server的check-local属性设置为false,特别是当你的code.py没有在网站的根目录下时。

如果您看到“不能导入flup”的错误消息,这说明你需要装下flup,使用easy_install flup命令即可。

从版本145开始,如果你的代码中使用了跳转就需要修改fastcgi配置bin-environment变量。如下示例配置

fastcgi.server = ( "/code.py" =>((   "socket" => "/tmp/fastcgi.socket",   "bin-path" => "/path/to/root/code.py",   "max-procs" => 1,   "bin-environment" => (     "REAL_SCRIPT_NAME" => ""   ),   "check-local" => "disable")))

翻译自: http://webpy.org/install#lighttpdfastcgi

评论关闭