Mercurial repos with Apache on Fedora 11
June 10, 2010
This covers getting a mercurial repository up and running on a fedora 11 box through Apache, using mod_wsgi. This is for use behind a firewall - there is no security on who can push and no requirement for SSL.
Install Software
Install mercurial binaries using the package manager.
yum install mercurial
Next, create somewhere for the repositories to live, and create a test project
mkdir -p /var/hg/repos cd /var/hg/repos mkdir test cd test hg init
Finally, we need a a directory to put the server config in
cd /var/hg mkdir cgi-bin cd cgi-bin
hgweb.config
This file lives in /var/hg/cgi-bin
and is referenced from the wsgi file below.
[web] style = coal push_ssl = false allow_push = * [paths] / = /var/hg/repos/**
hgwebdir.wsgi
This file also lives in /var/hg/cgi-bin
and is referred to from the apache config
from mercurial import demandimport; demandimport.enable() from mercurial.hgweb.hgwebdir_mod import hgwebdir application = hgwebdir('/var/hg/cgi-bin/hgweb.config')
Configure Apache
Configure a virtual host for Apache. This should be done in the standard Apache config structure, I created hg.conf
in /etc/httpd/conf.d
.
<VirtualHost *:80> ServerName hg.localhost DocumentRoot /var/hg/repos ErrorLog /var/log/httpd/hg-error_log CustomLog /var/log/httpd/hg-access_log common WSGIScriptAliasMatch ^(.*)$ /var/hg/cgi-bin/hgwebdir.wsgi$1 <Directory /var/hg/repos> Options FollowSymlinks DirectoryIndex index.html AllowOverride None Order allow,deny Allow from all </Directory> <Directory /var/hg/cgi-bin> Options ExecCGI FollowSymlinks AddHandler wsgi-script .wsgi AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>