Differences between revisions 2 and 3
Revision 2 as of 2006-06-18 14:05:54
Size: 3856
Editor: MishaS
Comment: few formatting fixes
Revision 3 as of 2006-06-18 14:11:29
Size: 4150
Comment: Added the standalone recipe.
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
I run all this on an Ubuntu system. Edgy one. :)
Line 14: Line 12:
  * But it is not necessary (see below)
Line 45: Line 44:
== Putting the right stuff in place == == Preparing the config ==
Line 47: Line 46:
Put the script in place (remember, we are still in that `working-directory/hg` :)):
{{{
$ sudo -u www-data cp hgwebdir.cgi /var/hg
$ sudo -u www-data chmod +x /var/hg/hgwebdir.cgi
}}}

Prepare the config:
Line 63: Line 55:
== Making it accessible == == Two possibilities ==
Either choose Apache or a standalone install.

=== Apache ===
==== Putting the right stuff in place ====

Put the script in place (remember, we are still in that `working-directory/hg` :)):
{{{
$ sudo -u www-data cp hgwebdir.cgi /var/hg
$ sudo -u www-data chmod +x /var/hg/hgwebdir.cgi
}}}

==== Making it accessible ====
Line 107: Line 111:
=== Standalone ===
Simply run {{{
su -u www-data hg serve --webdir-conf /var/hg/hgweb.config
}}} and enjoy this speedy method of serving multiple repos. It should be faster than using Apache.

TableOfContents

Publishing Repositories with `hgwebdir.cgi`

1. Introduction

Well, we have a certain setup with subversion. I'd like to reproduce it using Mercurial.

2. Pre-requisites

The installed software is:

  • apache2 (apache2, apache2-common, apache2-mpm-prefork, apache2-utils)
    • But it is not necessary (see below)
  • some version of mercurial (mine was 0.9 taken from Debian/unstable)
  • python:
    • Ubuntu/Edgy comes with python 2.4
    • you will need python2.4-dev package as well
  • sudo (in general, I prefer sudo to su)

3. Getting proper Mercurial

The whole point was to try pull/push over http. So the following was done (I'm a real newbie for hg, so please bear me :)):

$ cd working-directory
$ hg clone http://selenic.com/hg/
$ cd hg
$ hg pull http://hg.intevation.org/mercurial/crew
$ wget http://www.selenic.com/pipermail/mercurial/attachments/20060615/2893c03e/push-http.bin -O push-http.patch
$ hg import -p1 push-http.patch
$ python setup.py build
$ sudo python setup.py install

4. Directory Structure

Create the necessary directories:

$ sudo mkdir -p /var/hg/repos
$ sudo chown www-data:www-data -R /var/hg

It's usually a good idea to keep special directories out of the tree served by apache.

5. Preparing the config

$ cat > /tmp/hgweb.config
[collections]
repos/ = repos/
^D
$ sudo -u www-data cp /tmp/hgweb.config /var/hg
$ rm /tmp/hgweb.config

6. Two possibilities

Either choose Apache or a standalone install.

6.1. Apache

6.1.1. Putting the right stuff in place

Put the script in place (remember, we are still in that working-directory/hg :)):

$ sudo -u www-data cp hgwebdir.cgi /var/hg
$ sudo -u www-data chmod +x /var/hg/hgwebdir.cgi 

6.1.2. Making it accessible

Ok, now it's time for apache.

First of all, do not really change the config of apache directly:

$ sudo mkdir /etc/apache2/hg

Create the config with the following contents (e.g by using sudo vim /etc/apache2/hg/main.conf):

ScriptAliasMatch        ^/hg(.*)        /var/hg/hgwebdir.cgi$1

<Directory /var/hg>
  Options ExecCGI FollowSymLinks

  AllowOverride None
</Directory>

This config says that we are going to serve our repositories through '<yourhost>/hg/'.

Now make it really available, by changing your favourite site in /etc/apache2/sites-enabled. For this experiment I used /etc/apache2/sites-enabled/default:

  ...
  Include /etc/apache2/hg/main.conf
</VirtualHost>

Make sure that everything is OK:

$ sudo apache2ctl configtest
Syntax is OK

Restart your web server:

$ sudo apache2ctl stop
$ sudo apache2ctl start

Check if it works by directing your browser to <yourhost>/hg/

6.2. Standalone

Simply run

su -u www-data hg serve --webdir-conf /var/hg/hgweb.config

and enjoy this speedy method of serving multiple repos. It should be faster than using Apache.

7. You are done

Hooray!

8. Final Bits

8.1. Create a new repository

$ sudo -u www-data hg init /var/hg/repos/<repository-name>

8.2. Provide more information about it

Add the following to the /var/hg/repos/<repository-name>/.hg/hgrc file:

[web]
contact = Bilbo Baggins       # Whom to contact, plain text,
                              # no fancy stuff
description = My precious!    # Nice description what this is about,
                              # you can include HTML (like <a>)

8.3. Customize the look

Add the following to the /var/hg/repos/<repository-name>/.hg/hgrc file:

[web]
style = gitweb                # looks cleaner from my point of
                              # view :)
allow_archive = gz, zip, bz2  # If you think people should be able
                              # to download snapshots as .tar.gz,
                              # .zip, .tar.bz2 respectively

9. Disclaimer

Well, it works (worked) for me. Please do not hesitate to update this page to include small bits I've forgotten or just plainly am not aware of.

HgWebDirStepByStep (last edited 2018-11-26 18:38:58 by JordiGH)