Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2012-03-09 02:10:24
Size: 3830
Editor: AaronJensen
Comment: Simplifying setup instructions. Adding URL rewriting rules.
Revision 4 as of 2012-03-09 02:12:37
Size: 3840
Editor: AaronJensen
Comment: Removing non-wiki work from header
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
This page describes how to get HgWeb running on Windows Vista/2008 and 7/2008 R2. This page describes how to get Hg``Web running on Windows Vista/2008 and 7/2008 R2.
Line 13: Line 13:
Create an HgWeb website in IIS. We'll call the path to this website's root directory {{{HGWEB_ROOT}}}. Create an Hg``Web website in IIS. We'll call the path to this website's root directory {{{HGWEB_ROOT}}}.
Line 45: Line 45:
Create an empty file named {{{hgweb.config}}} in your Hg``Web root directory. This is where the HgWeb configuration goes once everything is working. Create an empty file named {{{hgweb.config}}} in your Hg``Web root directory. This is where the Hg``Web configuration goes once everything is working.
Line 57: Line 57:
Hit the hgweb.cgi script in your web browse and you should see the HgWeb interface. Hit the hgweb.cgi script in your web browse and you should see the Hg``Web interface.
Line 83: Line 83:
You should now be able to hit your website ''without'' {{{hgweb.cgi}}} in the URL and see the HgWeb UI. You should now be able to hit your website ''without'' {{{hgweb.cgi}}} in the URL and see the Hg``Web UI.

Installing HgWeb on Windows

1. Creating the HgWeb Website

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

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 an HgWeb website in IIS. We'll call the path to this website's root directory HGWEB_ROOT.

Create a web.config file in HGWEB_ROOT. Edit it to look like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="Python" path="*.cgi" verb="*" modules="CgiModule" scriptProcessor="PYTHON_HOME\python.exe -u &quot;%s&quot;" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
  </system.webServer>
</configuration>

You'll then need to enable the Python module. From a command prompt, run:

C:\Windows\system32\inetsrv\appcmd set config /section:isapiCgiRestriction /+"[path='C:\Python26\python.exe -u %22%s%22',description='Python',allowed='True']"

You should have everything configured to start running CGI scripts through Python. To test that it's working, create a test.cgi file in HGWEB_ROOT:

   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. Hit the test.cgi file in your web browser. If you see It Works!, you've got the Python CGI handler installed correctly.

Create an empty file named hgweb.config in your HgWeb root directory. This is where the HgWeb configuration goes once everything is working.

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 = "HGWEB_ROOT\hgweb.config

Hit the hgweb.cgi script in your web browse and you should see the HgWeb interface.

2. Configuring URL Rewrite Rules

Now, we need to create some URL rewrite rules so that URLs to your repositories don't have hgweb.cgi in them.

First, you'll need to download and install version 2 of the Url Rewrite Module.

Once that is finished, edit the HGWEB_ROOT\web.config file and add the following <rewrite> section under <system.webServer>:

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="rewrite to hgwebdir" patternSyntax="Wildcard">
          <match url="*" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
          <action type="Rewrite" url="hgweb.cgi/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

You should now be able to hit your website without hgweb.cgi in the URL and see the HgWeb UI.

HgWebInIisOnWindows (last edited 2018-04-16 13:04:02 by PeterSuter)