HgWeb on Windows 2016/IIS10
Martin Thomas
cythrault at gmail.com
Mon Feb 27 15:11:15 UTC 2023
Hi!
I'm trying to publish my hg repos through IIS. I don't have a choice
about the server version or web engine. I found a lot of information
out there but almost all are about very old Mercurial/IIS/Python
versions.
Here's what I have currently:
- WIndows 2016 with IIS10 (with CGI feature installed)
- Default Web Site listening on 80
- Cloned http://selenic.com/repo/hg under c:\inetpub\wwwroot\hg
- Installed Python 3.9.16 x64 system-wide under c:\Python39 (chose
3.9.x because hg debuginstall reports version 3.9.6.)
- Installed Mercurial 6.3.1 x64 using the "Mercurial 6.3.1 MSI
installer - x64 Windows (Python 3)" under C:\Program Files\Mercurial
- IIS_USR have read rights to C:\Python39 & C:\Program
Files\Mercurial\Lib|Templates
- IIS_USR have read rights to C:\inetpub\wwwroot\hg amd read/write for
C:\inetpub\wwwroot\hg\repos
- Configured a handler for *.cgi which added an allowed ISAPI and CGI
Restrictions for C:\Python39\python.exe -u "%s"
- The above also created a web.config file under the hg folder:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Python" path="*.cgi" verb="*"
modules="CgiModule" scriptProcessor="C:\Python39\python.exe -u
"%s"" resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
</configuration>
At this point, the test.cgi script suggested everywhere loads fine
(once adapted to Python3) and displayed the "It works" string in a
browser.
test.cgi:
print('Status: 200 OK')
print('Content-type: text/html')
print('<html><head>')
print('<h1>It works!</h1>')
- Updated C:\inetpub\wwwroot\hg\hgweb.cgi to:
#!c:\Python39\python.exe
import cgitb; cgitb.enable()
import sys; sys.path.insert(0, "C:\\Program Files\\Mercurial\\lib")
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
config = "c:\inetpub\wwwroot\hg\hgweb.config"
#application = hgweb(config)
application = hgweb(config.encode('utf-8'))
wsgicgi.launch(application)
- Copied a test repo under c:\inetpub\wwwroot\hg\repos
- Added a hgweb.config which looks like this:
[web]
templates = C:\Program Files\Mercurial\templates
push_ssl = false
allow_push = *
encoding = UTF-8
[paths]
/ = C:\inetpub\wwwroot\hg\repos\*
The result is the following error when loading hgweb.cgi:
--> --> -->
Traceback (most recent call last):
File "C:\inetpub\wwwroot\hg\hgweb.cgi", line 12, in <module>
wsgicgi.launch(application)
File "C:\Program Files\Mercurial\lib\mercurial\hgweb\wsgicgi.py",
line 23, in launch procutil.setbinary(procutil.stdin)
File "C:\Program Files\Mercurial\lib\mercurial\windows.py", line
297, in setbinary
if fno is not None and fno() >= 0:
io.UnsupportedOperation: fileno
I'm really stumped. I hope that someone can nudge me in the right
direction or state the obvious that I'm missing. :)
Cheers!
Martin
More information about the Mercurial
mailing list