This is a fast tutorial to set up, quick and fast, a mercurial server at Snow Leopard using Apache and cgi(the dirty party).
We need:
- One apache server, we’ll use the apache shipped with Snow Leopard
- Install the mercurial
- And the CGI script provide by Mercurial
First, install the mercurial, I used the macports version
sudo port install mercurial
Second, configure the httpd.
Create /etc/apache2/extra/httpd-hg.conf
ScriptAliasMatch ^/hg(.*) /var/hg/hgwebdir.cgi$1 #the last one is the the cgi file location
<Directory /var/hg>
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile /var/hg/.htpasswd # the user file
Require valid-user
Options ExecCGI FollowSymLinks
Order allow,deny
Allow from all
AllowOverride all
AddHandler cgi-script .cgi
</Directory>
Include at /etc/apache2/httpd.conf
Include /etc/apache2/extra/httpd-hg.conf
Third, create the repository, I’m using /var/hg.
sudo mkdir -p /var/hg/repos
Create the cgi configure file hgweb.config at /var/hg
[collections]
repos/ = repos/
[web]
style = gitweb
Download the cgi file from http://www.selenic.com/repo/hg-stable/raw-file/tip/hgwebdir.cgi and put at /var/hg
Uncomment the follow lines at hgwebdir.cgi and put the python location:
import sys
sys.path.insert(0, "/System/Library/Frameworks/Python.framework/Versions/2.6/bin")
Create the .htpasswd to authenticate users
htpasswd -c /var/hg/.htpasswd user
At /var/hg/repos, create a repository
hg init /var/hg/repos/<repository-name>
Edit the hgrc under /.hg
[web]
push_ssl = false #allow push using non-ssl connection
contact = user
description = teste
allow_push = user user2 #user allowed to push, must exist at .htpasswd
Do not forget to change the permissions at /var/hg to user _www and group _www
sudo chown -R _www:_www /var/hg
Start the apache server
sudo apachectl -k start
Now you have one repository, you can access using http://127.0.0.1/hg/
More info at http://mercurial.selenic.com/wiki/HgWebDirStepByStep