在lighttpd上使用fastcgi方式部署hg server[转载]

    技术2026-05-19  7

    lighttpd配置: #加载fastcgi模块 server.modules   += ( "mod_fastcgi" ) #定义一个新的web服务在81端口 $SERVER["socket"] == "0.0.0.0:81"{     server.document-root = "/home/hg/hgserver/" #下面是认证的配置     #auth.debug = 2     auth.backend = "plain"     auth.backend.plain.userfile = "/etc/lighttpd/lighttpd_plain.user"     #auth.backend = "htdigest"     #auth.backend.htdigest.userfile = "/etc/lighttpd/lighttpd.user"     auth.require = ("/" => (     "method" => "digest",     "realm" => "Mercurial Repository",     "require" => "valid-user"     #"require" => "user=see|user=test"     )) #fastcgi配置     fastcgi.server=(         "/hg_fastcgi.fcgi" =>(             "hg" => (                 "bin-path" => "/usr/bin/python /home/hg/hgserver/hg_fastcgi.py socket=/tmp/hg.socket-0",                 "socket" => "/tmp/hg.socket",                 "min-procs" => 1,                 "max-procs" => 1,                 "idle-timeout" => 120,                 "check-local" => "disable",           )         ),     )     ## error-handler for status 404     ##server.error-handler-404  = "/app.fcgi"     url.rewrite-once = (     "^(/.*)$" => "/hg_fastcgi.fcgi$1",     ) } 注意事项: 1.刚开始加认证部分时,出现个怪异情况:lighttpd启动正常,ie或firefox链接那需要认证的url时,很久没反应,一直在读取状态;用sniffer查看网络包,发现lighttpd返回了需要认证并在header中有connection close信息,但连接一直不断开。后来,将认证配置移到fastcgi配置之前,将认证模块加载也放在部分模块之前,这怪异问题就解决了。 2.lighttpd也可以象apache那样,由lighttpd动态启动、管理fcgi程序。这个方法google了很多文章都没有讲,一般都是fcgi程序需要独立运行。配置如上,bin-path是设置启动命令,这里传了个socket参数给fcgi程序。这里需要注意:fastcgi配置的socket参数是"/tmp/hg.socket",而fcgi程序的socket=socket=/tmp/hg.socket-0,多了-0。由于lighttpd可以启动多个fcgi程序(上面配置max-procs=1,最多只启动一个fcgi),那多个fcgi程序需要使用多个unix socket与lighttpd通讯。lighttpd默认会依次加入-0~-N。不过这个对socket的修改好像并没有通知给fcgi,不知道某个fcgi中如何知道使用的是socket-几? 3.具体lighttpd的fastcgi配置参考: http://redmine.lighttpd.net/projects/1/wiki/Docs:ModFastCGI Do you really need to proxy to hg serve?  It's pretty easy to get hgwebdir working with lighttpd: server.modules += ( "mod_rewrite" ) server.modules += ( "mod_cgi" ) url.rewrite-once = ( "^/hg(.*)?$" => "/hgwebdir.cgi$1",                      "^/mercurial(.*)?$" => "/hgwebdir.cgi$1" ) $HTTP["url"] =~ "^/hgwebdir.cgi(.*)?$" {              server.document-root = "/var/hg/"              cgi.assign = ( ".cgi" => "/usr/bin/python" ) } Copy hgwebdir.cgi to /var/hg/. Create an hgweb.config in /var/hg that looks something like: [collections] repos/ = repos/ Then put your repositories in subdirectories of /var/hg/repos/.
    最新回复(0)