views:

518

answers:

3

I have tried to host a Mercurial HG repository using a Scriptalias.

ScriptAlias /hg/ "htdocs/hgwebdir.cgi"

If I go to Chrome it display the contents of the cgi file. In IE it does render however images and links are not displayed. In either case the repository I want to display is not shown.

Has anyone managed to get this working with VisualSVN? Also will this work if I have windows authentication and https?

Thanks

David

A: 

You can run hgwebdir behind different authentication and https modules just fine, provided your webserver handles them before the REMOTE_USER variable is handed off to the CGI.

I don't know visualsvn, but your ScriptAlias looks a lot like Apache. Do you need an AddHandler line for .cgi?

Ry4an
Is that AddHandler line supposed to be all that is needed to execute CGI on a regular apache server?
ranomore
In Apache you can authorize the execution of files using "ExecCGI", "AddHandler cgi-script .cgi", and "ScriptAlias". I use the later two.
Ry4an
+3  A: 

Assuming you have Python 2.6 installed and working, here are the steps that I took.

Obtain "mod_cgi.so" built for Apache 2.2 Win32 and place it in "C:\Program Files\VisualSVN Server\bin".

Paste the following in "C:\Program Files\VisualSVN Server\conf\httpd-custom.conf"

LoadModule cgi_module bin/mod_cgi.so
ScriptAliasMatch ^/hg(.*) "cgi-bin/hgwebdir.cgi$1"

Create the cgi-bin directory, "C:\Program Files\VisualSVN Server\cgi-bin". And place hgwebdir.cgi in it. Make sure it looks similar to the following:

#!c:/Python26/python.exe -u

import sys
sys.path.insert(0, "C:\Program Files\Mercurial\library")

import cgitb
cgitb.enable()

from mercurial.hgweb.hgwebdir_mod import hgwebdir
import mercurial.hgweb.wsgicgi as wsgicgi

application = hgwebdir('hgweb.config')
wsgicgi.launch(application)

Create a file called hgweb.config in the cgi-bin directory.

[paths]
/ = c:/HgRepositories/*

Copied "C:\Program Files\Mercurial\templates" to "C:\Program Files\Mercurial\library\templates".

Create "C:\HgRepositories" folder and "hg init c:\HgRepositories\test".

Restart VisualSVN Server, open browser, enjoy your Mecurial repository.

h0tw1r3
+4  A: 

Here's a alternative setup using mod_wsgi (fast!), combined repository directory, and you can manage Mercurial repository level access from the VisualSVN Server GUI.

Download mod_wsgi.so for Apache 2.2 Win32 and place in "C:\Program Files\VisualSVN Server\bin".

Copy hgwebdir.wsgi from your Mercurial installation (contrib directory) to "C:\Program Files\VisualSVN Server\". It should look something like this:

import sys
sys.path.insert(0, "C:\Program Files\Mercurial\library")
from mercurial.hgweb.hgwebdir_mod import hgwebdir
application = hgwebdir('hgweb.config')

Create the config file "C:\Program Files\VisualSVN Server\hgweb.config".

[paths]
/ = c:/Repositories/*

Paste the following in "C:\Program Files\VisualSVN Server\conf\httpd-custom.conf". You should adjust the Auth* values based on the section of httpd.conf.

LoadModule wsgi_module bin/mod_wsgi.so
WSGIScriptAlias /hg "hgwebdir.wsgi"

<Location /hg/>
    AuthName "Mercurial Repositories"
    AuthType VisualSVN
    AuthzVisualSVNAccessFile "C:/Repositories/authz-windows"
    AuthnVisualSVNBasic on
    AuthnVisualSVNIntegrated off
    AuthnVisualSVNUPN Off

    SVNParentPath "C:/Repositories/"

    require valid-user
</Location>

Create a Mercurial repository:

hg init C:\Repositories\hgtest

You should now be able to access /hg through your browser, and manage repository level authorization through the VisualSVN Server tool.

h0tw1r3
dvkwong
5 seconds after posting my last comment I finally got this to work! Copied Templates folder to the library folder as per previous answer.Extra Steps to follow:1. Extract libraries.zip in Mercurial install to a folder called libraries.2. Copy Templates folder to the libraries folder.3. Make sure you install Python 2.6.Thanks!
dvkwong