Feb 042011
 

I already went through motions of installing Mercurial server on Ubuntu. However, that left us with nasty looking URL with hgweb.cgi in it (e.g. http://192.168.0.2/hgweb.cgi/TestRepo/). Can we make it nicer?

We need to edit “/etc/apache2/sites-available/hg” in order to add two highlighted lines (I kept all other lines for clarity):

NameVirtualHost *
<VirtualHost *>
    ServerAdmin webmaster@localhost
    DocumentRoot /srv/hg/cgi-bin
    <Directory "/srv/hg/cgi-bin/">
        SetHandler cgi-script
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog /var/log/apache2/hg.log
    <Location />
        AuthType Basic
        AuthName "Mercurial"
        AuthUserFile  /srv/hg/.htpasswd
        Require valid-user
    </Location>
    RewriteEngine on
    RewriteRule (.*) /srv/hg/cgi-bin/hgweb.cgi/$1
</VirtualHost>

Next thing to do is enabling Apache’s mod_rewrite module and restarting apache:

$ sudo a2enmod rewrite
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!

$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                                                                                              apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.2 for ServerName
[Tue Feb 01 09:42:15 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.2 for ServerName
[Tue Feb 01 09:42:16 2011] [warn] NameVirtualHost *:80 has no VirtualHosts

If everything went fine you should be access your repositories without hgweb.cgi, e.g. http://192.168.0.2/TestRepo/. Not a big change but it does look much better.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>