mercurial web server deployment on nginx

Maxim Khitrov mkhitrov at gmail.com
Mon Aug 20 09:57:54 CDT 2007


On 8/20/07, Manlio Perillo <manlio_perillo at libero.it> wrote:
> Hi.
>
> I'm new to Mercurial.
>
> I want to publish my Mercurial repositories on a "public" HTTP server.
>
> The problem is that:
> 1) The builtin web server is not ideal.
> 2) nginx does not support CGI
> 3) nginx does not execute a fastcgi process for you
>     (like Apache or lighttpd).
>
>
> So I need to write a script that will setup the server (using flup or
> Aspen), with support to daemonization, setuid/gid and so on.
>
> There is something already available?
> Dos Mercurial support the deployment method used by Apache mod_wsgi (so
> I can write the script once for a given web server).
>
>
> Thanks  Manlio Perillo

Missed my thread by a day :)

This is what you need:
http://selenic.com/repo/hg/raw-file/tip/contrib/hgwebdir.fcgi

I'm using it in combination with lighttpd's spawn-fcgi binary and so
far nginx seems to be pretty happy. To start the server you would do
something like this:

spawn-fcgi -f <path to hgwebdir.fcgi> -u <user> -g <group> -s <unix
socket> -P <pid> 2> /dev/null

You will have to make sure that nginx passes PATH_INFO variable to the
socket, otherwise you will not be able to access any repositories.
There are a few problems with this approach. First of all, if you
don't redirect stderr output you will keep getting boken pipe error. I
don't know why that happens. Second is that if you try to access a
non-existent repository you will see python's traceback if using
gitweb template. In the regular CGI script you could comment out
cgitb.enable() and that would hide the traceback. With FastCGI the
only option seems to be to download the latest gitweb template from
tip and replace the installed one.

- Max


More information about the Mercurial mailing list