Installing HgWeb on Windows

This page describes how to get HgWeb running on Windows Vista/2008 and 7/2008 R2.

1. Installing the Python CGI Handler

Install Python 2.6. By default, this installs to C:\Python26. On this page, the Python installation folder is referred to as PYTHON_HOME.

Create a directory for the HgWeb website. Open Internet Information Services manager. Right-click the Sites folder and choose Add Web Site. Fill in your site's settings. (The Physical path should be set to your HgWeb website directory.) Click OK.

Select the HgWeb website and double-click Handler Mappings. Click the Add Script Map... action from the Actions menu (its in the upper right corner). In the Add Script Map dialog box, enter *.cgi for Request Path, C:\Python26\python.exe -u "%s" for Executable, and Python for Name. Click OK. You will then be prompted to allow the new ISAPI extension. Click Yes. If you don't, you'll get 404 errors when you try and execute a cgi script.

In your HgWeb directory, create a text file named test.cgi. Edit it to contain the following text:

   1 print 'Status: 200 OK'
   2 print 'Content-Type: text/html'
   3 print
   4 print '<html><body><h1>It Works!</h1></body></html>'

Save the file. Open a web browser and go to this test.cgi file, e.g. If you see It Works!, you've got the Python CGI handler installed correctly. You can now install HgWeb.

2. Installing HgWeb

Create an empty file named hgweb.config in your HgWeb root directory.

Download and run the Mercurial Python module installer (it's the one whose description says "use this for running hgweb"). After installation, you should see mercurial and hgext directories in your PYTHON_HOME\Lib\site-packages directory. If you don't see those directories, you chose the wrong installer.

Download the hgweb.cgi script for your version of Mercurial. Browse the Mercurial source code. Click the the tag for your version, click Browse in the navigation menu, click the hgweb.cgi script, then right-click Raw from the navigation menu, choose Save As... and save the file into your HgWeb directory.

Open hgweb.cgi and change the value of the config variable to point to the hgweb.config file you created earlier:

   1 config = "DRIVE:\PATH\TO\HGWEB\DIRECTORY\hgweb.config

You should now be able to browse to hgweb.cgi (e.g. and see the HgWeb interface.