Note:

This page appears to contain material that is no longer relevant. Please help improve this page by updating its content.

This page describes how to setup the hgwebdir.cgi script on a Unix server to which you only have FTP access. See also HgWebDirStepByStep.

The multiple repository CGI server is now described in the Publishing Repositories document together with other related information. However, this guide gives some additional useful details for publishing repositories.

Starting with version 1.6 of Mercurial, the hgwebdir.cgi script has been unified with the hgweb.cgi script. Wherever hgwebdir.cgi is referred to in these directions, you can substitute the hgweb.cgi script instead.

Prerequisites

FTP access, Python, and a cgi-bin directory

Consider using a webshell like PHP Shell

How to do it

  1. Make a directory /path/to/repos to which the webserver may write

  2. Ensure that the directory is writable
    • Upload test.sh

      echo test > /path/to/repos/test

      to your cgi-bin/ and make it executable: 'chmod a+x test.sh'.

    • Open http://yourdomain/cgi-bin/test.sh - you'll get an server error, but that's okay

    • Now there should be a file /path/to/repos/test

    • Delete the file and test.sh

  3. Upload a recent version of Mercurial to the server (e.g. the whole /usr/lib/python2.4/site-packages/mercurial/) into /path/to/private_python_libs/mercurial. It must be compiled for the architecture of the server (you may try to extract a precompiled version from a deb or rpm). It was reported that deleting the *.pyc files helped.

  4. Make a new subdir cgi-bin/hg/

  5. Change hgwebdir.cgi locally to load Mercurial on the server:

    # Uncomment to send python tracebacks to the browser if an error occurs:
    import cgitb
    cgitb.enable()
    
    # adjust python path if not a system-wide install:
    import sys
    sys.path.insert(0, "/path/to/private_python_libs/") #note that this is one dir up from Mercurial

    and upload it into cgi-bin/hg/. Make it executable.

  6. Make a hgweb.config:

    [collections]
    /path/to/repos/ = /path/to/repos/

    and upload it to cgi-bin/hg/.

  7. Upload an existing repository myrep into /path/to/repos/myrep and make it writable by the server.

  8. You should now be able to access it at http://yourdomain/cgi-bin/hg/hgwebdir.cgi

  9. You will probably want to change /path/to/repos/myrep/.hg/hgrc to contain something like:

    [web]
    contact     = John Doe
    description = This my rep
    push_ssl = false
    allow_archive = gz zip bz2
    style = gitweb
    
    #everybody may change it!
    allow_push   = *


CategoryHowTo

HgWebDirStepByStepFtpOnly (last edited 2012-05-13 09:07:58 by 62)