eWorld.UI - Matt Hawley

Ramblings of Matt

Setting up Mercurial server in IIS7 using a ISAPI module

April 8, 2010 18:10 by matthaw
In addition to blogging, I'm also using Twitter. Follow me @matthawley

 

Previously, Jeremy Skinner posted a very thorough guide on setting up Mercurial in IIS. The difference between his guide, and what I'll be walking you through, is how Mercurial is hosted in IIS. Where he shows you using a CGI script that executes python.exe, my guide will show you how to use isapi-wsgi to host Mercurial. The biggest benefits of using isapi-wsgi over executing python.exe, is the raw processing speed and the overall throughput your server can handle.

 

Note: This post uses Mercurial 1.5.1, Python 2.6.5 although it should work for all older/future versions released.

 

Packages Installation

 

Install Python

The reason you need to install Python first, is that all subsequent installations will install directly into the Python installation (in the Lib\site-packages folder), including Mercurial. It is important to note that you will need to install the version of Python that Mercurial was built against, as well as installing the x86 version (yes, even if you're on a x64 platform). Download and install Python 2.6.5.

 

Install PyWin32

This component is needed to run certain win32 functions (specifically for ISAPI) that isapi-wsgi needs. Download and install this package, letting it determine the default installation path for you.

 

Install Mercurial Source

Normally, you would download the binary package for Mercurial, but for this process to work, you will need to utilize the source code package. Download the mercurial-1.5.1.win32-py2.6.exe package and install it. Just as PyWin32, let it determine the default installation path for you.

 

Install isapi-wsgi

This is the glue that binds everything together. It's used to build a shim based on a python script that you setup (later). Download and install this package, also letting it determine the default installation path for you.

 

Get hgwebdir_wsgi

You will now need to download the python script hgwebdir_wsgi.py. This is the script that you will configure to and execute to build the ISAPI shim DLL. This script is apart of the Mercurial source code, and is not distributed with the binaries or the earlier installation. To get it, you can download the source code from the Mercurial site, or clone their repository by executing the following command

hg clone http://selenic.com/repo/hg#stable

Once you have the source, you can find the script in the contrib/win32 directory.

 

image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Configuration


Note: The following steps assume that you already have IIS installed. If you do not, please refer to Jeremy's guide for these steps.

 

1. Create a folder that will be used by the IIS website for hosting your Mercurial installation. For example, C:\inetpub\hg

2. Copy hgwebdir_wsgi.py to the location created in step 1

3. Open hgwebdir_wsgi.py in a text editor, and configure the following settings

hgweb_config = r'c:\inetpub\hg\hgweb.config' 
path_prefix = 0

4. Open a command prompt changing your directory to c:\inetpub\hg

5. Execute python hgwebdir_wsgi.py which will generate a DLL shim called _hgwebdir_wsgi.dll

6. Create your hgweb.config file with the following content

[paths]
/ = c:\repos\*

7. In IIS Manager, create a new application pool called "Mercurial" and ensure that the "Enable 32-bit Applications" is set to true.

 

image

 

8. Create a new website pointing it to the location in step 1.

 

image

 

9. Open up the Handler Mappings for your new web site.

 

image

 

10. Add a new "Wildcard Script Map" with the Executable location pointing to the Shim DLL created in step 5. Give it the name Mercurial-ISAPI.

 

image

 

11. Click the OK button, and when it prompts you to allow this ISAPI extension, click "Yes".

 

image

 

12. Now, browse to your newly created website, and you should see hgwebdir being served.

 

image

 

13. Now, run the following command to create a new empty repository, and then refresh your browser.

hg init c:\repos\test
image

 

All Setup!

 

At this point, your Mercurial server is setup. You'll also notice that there's no need for URL rewriting unlike the the CGI approach. You can start pulling / pushing changes to your repository. While this setup requires more steps and dependencies, the benefit is that you are running completely within IIS gaining it's benefits of application isolation, memory management, and improved performance.



Categories: Mercurial
Actions: E-mail | Permalink | Comments (39) | Comment RSSRSS comment feed

Comments

April 8. 2010 19:56

Social comments and analytics for this post

This post was mentioned on Twitter by matthawley: Blogged: Setting up Mercurial server in IIS7 using a ISAPI module http://bit.ly/bgyJEK

uberVU - social comments

April 8. 2010 20:05

Pingback from topsy.com

Twitter Trackbacks for
        
        Setting up Mercurial server in IIS7 using a ISAPI module
        [eworldui.net]
        on Topsy.com

topsy.com

April 13. 2010 12:12

Setting up Mercurial server in IIS7 using a ISAPI module

I'm using Twitter. Follow me @matthawley Previously, Jeremy Skinner posted a very thorough guide on setting

eWorld.UI - Matt Hawley

April 13. 2010 14:58

Great guide. Thank you!

andrex

April 16. 2010 13:07

Do you know if this will work under IIS 6?

Tim Murphy

April 20. 2010 22:26

@Tim Yes - it sure does. We have it working in IIS6 at work.

matthaw

April 28. 2010 08:29

Hi Matt

Thanks for a great post, I've tried to set up mercurial on my Server 2003 machine with IIS6, following your instructions (and then guessing at the settings for IIS6), but run into a problem. I added the app pool and web site, added the dll to the wild card application map in the home directory config dialog, added the dll as an ISAPI filter, enabled the dll in web service extensions, and I can browse to the mercurial page. It shows the list of repos, but doesn't look like your screen shot, the hg image isn't there (broken image in FF), nor any of the styling. It does show the repos, and when I add repo it shows it, however clicking the repo link results in a 404 error.

Can you suggest any other settings I may have missed? Are there any security settings that need to be set up on the repo folder, or on the python or mercurial folders?

Thanks!

Matt

Matt Evans

April 28. 2010 14:20

@Matt - I worked w/ TJ via Twitter on this. It seems that in IIS6, when you setup your wildcard script mapping, that you need to make sure the "Verify file exists" checkbox is unchecked.

matthaw

April 28. 2010 17:03

Hi Matt & TJ

That file exists setting worked for me too! I guess it's trying to verify that each file/folder the client requests is present on the server (which they won't be as everything seems to be done through the filter).

Thanks for the help and the quick reply!

Matt

Matt Evans

April 28. 2010 17:08

Newbie here...
How do I make the hg repositories list url something other than root?

What I want is something like:
http://myserver/hg

Also, why did you use port 81?

Ryan

April 28. 2010 21:23

@Ryan - set "path_prefix = 1" and I used port 81 because port 80 was already taken on my box Smile You can use any port, though I recommend using SSL due to authenticating requires basic auth.

matthaw

April 30. 2010 21:10

Pingback from blog.djmatty.com

Matt's blog  » Blog Archive   » Mercurial and hosting it as an ISAPI module under IIS6

blog.djmatty.com

May 4. 2010 19:09

Setting up Mercurial Under IIS 6

Setting up Mercurial Under IIS 6

Rob Garfoot's Blog

May 13. 2010 01:03

Pingback from christianpayne.com.au

Setting up Mercurial server in IIS7 « A Digital Idea

christianpayne.com.au

May 14. 2010 14:03

Getting it working correcly for small repos but getting HTTP Error 404: Not Found on bigger ones.
Tried to increase timeout but it seem that is another issue...
Any clues about that?

sameh

May 14. 2010 14:15

Thanks,
All is working on small repository push. On bigger ones I am getting HTTP Error 404: Not Found.
What could be the issue?

sameh

May 20. 2010 14:17

Pingback from 499.tvshowzone.com

Buick Skylark Engine Cutlass Supreme, Skylark Stock Buy

499.tvshowzone.com

May 21. 2010 10:59

You need to allow ISAPI extensions in IIS setup, or you'll be unable to add the handler mapping due to a missing module.

Rik Hemsley

May 28. 2010 13:50

Pingback from tune-up-pc.com

Tune Up Your PC  » Post Topic   » Blog Post: Setting up Mercurial Under IIS 6

tune-up-pc.com

June 15. 2010 03:29

I've got 500 error and the following in the event log:
The pyISAPI extension encountered an error.
Failed to import callback module 'hgwebdir_wsgi'
The last windows error was: The system cannot find the file specified.

How to fix that?

kinger

June 19. 2010 12:39

Very helpful, thanks Matt!

Ken

June 29. 2010 05:00

Pingback from eugeneduvenage.com

Source Control – Part 3 – Installing and Configuring a Mercurial Server | eugene duvenage

eugeneduvenage.com

November 6. 2010 16:17

Pingback from thestandardoutput.com

[delicious | grep links | blogger] for 2010-11-06 at The Standard Output

thestandardoutput.com

April 20. 2011 19:08

Pingback from rubot99.wordpress.com

Setting up Mercurial for a Dev shop « rubot

rubot99.wordpress.com

May 8. 2011 17:41

Pingback from v-net.ch

Mercurial hgweb – 404 – File or directory not found. « V-Net

v-net.ch

July 14. 2011 17:38

Pingback from firegarden.com

Hosting Mercurial Repo IIS7 Windows Server 2008R2 x64 Python ISAPI CGI

firegarden.com

July 2. 2012 04:04

Mercurial and hosting it as an ISAPI module under IIS6

Mercurial and hosting it as an ISAPI module under IIS6

Name of the blog

September 16. 2012 14:49

Pingback from pteradigm.com

Mercurial on IIS 7 – x86 or x64 « pteradigm

pteradigm.com

June 4. 2014 18:05

Pingback from leapersignal.wordpress.com

Running Mercurial on Apache with Windows Server 2008 | Leaper Signal

leapersignal.wordpress.com

August 8. 2014 20:49

Pingback from nuttanun4u.wordpress.com

Mercurial Link ต่าง ๆ ที่เกี่ยวข้อง | nuttanun4u

nuttanun4u.wordpress.com

October 14. 2015 03:15

Pingback from itsprite.com

Python:Mercurial and hgweb on IIS 7.5 – python error – IT Sprite

itsprite.com

January 5. 2016 00:15

Pingback from askandans.cloverink.com

How to setup Mercurial and hgwebdir on IIS? | ASK AND ANSWER

askandans.cloverink.com

March 17. 2016 02:02

Pingback from blogs.msdn.microsoft.com

Setting up Mercurial Under IIS 6 | UK Premier Support for Developers

blogs.msdn.microsoft.com

July 5. 2017 03:02

Mercurial and hosting it as an ISAPI module under IIS6

Mercurial and hosting it as an ISAPI module under IIS6

DJMatty's Blog

May 5. 2018 17:41

Pingback from exceptionshub.com

How to setup Mercurial and hgwebdir on IIS? - ExceptionsHub

exceptionshub.com

January 7. 2019 16:52

Pingback from pythoncharm.com

Mercurial and hgweb on IIS 7.5 – python error – PythonCharm

pythoncharm.com

February 12. 2020 10:58

Pingback from inneka.com

How do I set up Mercurial and hgwebdir on IIS? – inneka.com

inneka.com

March 18. 2022 06:07

Pingback from codeutility.org

windows - How do I set up Mercurial and hgweb on IIS? - Code Utility - Code Utility

codeutility.org

October 21. 2022 23:28

Pingback from 123stack.one

如何在 IIS 上設置 Mercurial 和 hgweb? - 123stack

123stack.one

Comments are closed

Copyright © 2000 - 2024 , Excentrics World