Installing Mercurial on IIS 7

Here's how I got a Mercurial server up and running using Windows 2008 and IIS 7:

  1. Download ActiveState ActivePython Choose the 32-bit version regardless of the Windows flavor.
  2. Install ActivePython using the default installation path of C:\Python26.
  3. Download the binary version of PyWin32
  4. Install PyWin32 using the default installation path of C:\Python26
  5. Download the source code of Mercurial
  6. Extract Mercurial to C:\Mercurial_src
  7. Open a cmd window and change directory to the above folder:

    cd \Mercurial_src
  8. Run the following commands:

    python --pure build_py -c -d . build_ext -i build_mo --force
    python --pure install --force
  9. Download isapi-wsgi
  10. Install isapi-wsgi using the default installation path of C:\Python26
  11. Create a folder for a new website somewhere:

    mkdir \inetpub\
  12. Copy C:\Mercurial_src\contrib\win32\ to the new website’s root folder:

    cp  C:\Mercurial_src\contrib\win32\ C:\inetpub\\
  13. Open in a text editor, and configure the following settings:

    hgweb_config = r'C:\inetpub\\hgweb.config'
    path_prefix = 0
  14. Create a folder for the repositories somewhere:

    mkdir \Repositories
  15. Create C:\inetpub\\hgweb.config with this content:

    / = C:\Repositories\*
  16. Execute python which will generate a DLL shim called _hgwebdir_wsgi.dll:

    cd \inetpub\
  17. Start IIS Manager:

  18. Create an application pool; set its .NET version to “No Managed code” and enable 32-bit apps under “Advanced Settings”
  19. Create a website with the root folder C:\inetpub\ and set its application pool to the newly created application pool
  20. Double-click “Handler Mappings”
  21. Click “Add Wildcard Script Map”
  22. As Executable choose the dll file in C:\inetpub\ (it was created when you ran previously)
  23. As name enter “Mercurial-ISAPI” (it doesn’t matter really)
  24. Click “OK” and “Yes” to allow this ISAPI extension
  25. Browse to your new website in a browser and you should now be greeted by Mercurial
  26. Create a repository in your repositories path:

    cd \Repositories
    hg init testrepo
  27. Browse to your new website again and the repository “testrepo” should now be displayed
  28. Don’t forget to set up authentication in IIS Manager to only allow authorized developers to access the repositories.
  29. Restart IIS: