Jan 14 2010
∞
Installing Mercurial hgwebdir.cgi on Windows 2003, Apache2
UPDATE:
Clay Lenhart sent me the following solution to the timeout issue:
cd \inetpub\AdminScripts\
cscript adsutil.vbs GET /W3SVC/CGITimeout
cscript adsutil.vbs SET /W3SVC/CGITimeout 3000
Thank you!
As I posted previously I had installed Mercurial cgi-bin on Windows 2003 and IIS 6. After some promising rounds I decided to use it in production. At least this was my idea.
No matter how many times I tried cloning one of my project (about 40MB) the hg clone command (over https) always returned an error like this:
transaction abort!
rollback completed
abort: premature EOF reading chunk (got 36750 bytes, expected 131164)
I had no choice but to install Apache2.
Here is my walkthrough.
- Download and install Python 2.6.4 to C:\Mercurial\Python
- Download and install MiniGW 5.1.6
- Choose the Download and Install Option.
- Choose the Current Package Option to Install.
- For the Components to Install Select the “Minimal” option. Install to C:\Mercurial\MinGW
- Add to path “C:\Mercurial\Python\Scripts;C:\Mercurial\Python;C:\Mercurial\MinGW\bin”
- Download and unzip Mercurial source to C:\Mercurial\Source
- Build Mercurial from command line:
python setup.py build --force -c mingw32
python setup.py install --force --skip-build
- Create default hgrc from command line type:
cd %userprofile%
copy con .hgrc
[ui]
username = Firstname Lastname <firstname.lastname@example.net>
verbose = True
- CTRL-Z
- ENTER
- hg debuginstall should display “No problems detected”
- Download and install Apache2.2 + OpenSSL. Default settings are fine except path where use c:\Mercurial\httpd
- Open c:\Mercurial\httpd\conf\http.conf with a text editor.
ReplaceListen 80
withListen 8080
Replace#LoadModule ssl_module modules/mod_ssl.so
withLoadModule ssl_module modules/mod_ssl.so
Replace#Include conf/extra/httpd-ssl.conf
withInclude conf/extra/httpd-ssl.conf
- Open c:\Mercurial\httpd\conf\extra\httpd-ssl.conf with a text editor.
ReplaceListen 443
withListen 8088
Replace<VirtualHost _default_:443>
with<VirtualHost _default_:8088>
ReplaceSSLCertificateFile "C:/Mercurial/httpd/conf/server.crt"
withSSLCertificateFile "C:/Mercurial/httpd/conf/localhost.cert"
*use your domain instead of localhost
ReplaceSSLCertificateKeyFile "C:/Mercurial/httpd/conf/server.key"
withSSLCertificateKeyFile "C:/Mercurial/httpd/conf/localhost.key"
- Open a command prompt and type the following. When asked for common name use te actual domain (localhost in this example)
cd c:\Mercurial\httpd\bin
openssl req -config ../conf/openssl.cnf -new -out localhost.csr -keyout
openssl rsa -in localhost.pem -out localhost.key
openssl x509 -in localhost.csr -out localhost.cert -req -signkey localhost.key -days 365
copy localhost.cert ..\conf
copy localhost.key ..\conf
- Create a C:\Mercurial\Repositories directory
- Copy the hgwebdir.cgi file from the C:\Mercurial\Source to C:\Mercurial\httpd\cgi-bin\
- Create hgweb.config in C:\Mercurial\httpd\cgi-bin\
- Insert text in hgweb.config
[paths]
/ = C:\Mercurial\Repositories\ - Create a test repository
cd C:\Mercurial\Repositories
md test
cd test
hg init
- Enable push for this repository
- create hgrc file with notepad in cd C:\Mercurial\Repositories\test.hg
- insert the following text
[web]
allow_push = * - Open c:\Mercurial\httpd\cgi-bin\hgwebdir.cgi with a text editor able to handle unix style now line breaks. Replace
#!/usr/bin/env python
with#!C:/Mercurial/Python/python.exe
Replace#sys.path.insert(0, "/path/to/python/lib")
with#sys.path.insert(0, "C:/Mercurial/Python/Lib")
- This is an optional step. If you don’t want authentication skip to the next step.
Open c:\Mercurial\httpd\conf\http.conf with a text editor
Replace<Directory "C:/Mercurial/httpd/cgi-bin">
with
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory><Directory "C:/Mercurial/httpd/cgi-bin">
Order allow,deny
Allow from all
AuthName "frantic"
AuthType Basic
Require valid-user
AuthUserFile "C:/mercurial/htpasswd"
</Directory>
Open a command prompt and type the followingcd C:\Mercurial\httpd\bin
htpasswd -c htpasswd YourUserName
copy htpasswd c:\mercurial
- Test your newly configured website: eg. http://localhost:8088/cgi-bin/hgwebdir.cgi