Mercurial Server Install for SLES

The following assumptions have been made.  You have an apache server installed, configured, and running with vhosts.  You have also installed any of the the mercurial dependencies before installation.

  1. Get the source code for Mercurial from http://www.selenic.com/mercurial/wiki/index.cgi/Mercurial
  2. Extract the source code and follow the UnixInstall guide: http://www.selenic.com/mercurial/wiki/index.cgi/UnixInstall
  3. For SLE make sure you do the following:
    # cd hgext/inotify/linux/
    # vi _inotify.c
    In order to build the inotify hgext on SUSE/SLES you may have to edit _inotify.c and change the include line for inotify.h from:
    #include <sys/inotify.h>
    to:
    #include <linux/inotify.h>
    # patch -p0 < /home/sjcundy/mercurial-hgk-path-fix.diff
    Follow the opensuse factory mercurial spec file for installation
    Copy the sample.hgrc file to /etc/mercurial/hgrc.d/
  4. Configure directories for apache integration
    # mkdir -p /srv/mercurial/repos
    # vi /srv/mercurial/hgweb.conf

    [collections]
    /srv/mercurial/repos/ = /srv/mercurial/repos/

    [web]
    style = gitweb

  5. Chown for apache
    # chown -R wwwrun:www /srv/mercurial/
  6. Make the apache directoires
    # mkdir -p /srv/www/vhosts/mercurial.example.com/{http,https,cgi-bin}
  7. Copy the hgwebdir.cgi file from the source you downloaded to cgi-bin
    # cp hgwebdir.cgi /srv/www/vhots/mercurial.example.com/cgi-bin/
  8. Modify hgwebdir.cgi to point to the hgweb.config file /srv/mercurial
    # vi /srv/www/vhosts/mercurial.example.com/cgi-bin/hgwebdir.cgi

    application = hgwebdir('/srv/mercurial/hgweb.config')

  9. Create a mercurial.conf file for apache ldap based authentication
    # vi /etc/apache2/custom/mercurial.conf

    <Location />
    Order deny,allow
    Deny from all
    AuthName "Mercurial Repositories"
    AuthType Basic
    AuthBasicProvider ldap
    AuthzLDAPAuthoritative Off
    AuthLDAPUrl ldap://ldap.example.com:389/o=ouc?uid?sub?(objectClass=posixAccount)
    Satisfy Any
    Require valid-user
    </Location>

  10. Create a mercurial.example.com vhost conf file
    # vi /etc/apache2/vhosts.d/mercurial.ok.ubc.ca.conf

    <VirtualHost *:80>
    ServerName mercurial.example.com
    ServerAlias hg.example.com
    ServerAlias mercurial
    ServerAlias hg

    DocumentRoot /srv/www/vhosts/mercurial.example.com/http
    ErrorLog /var/log/apache2/mercurial.example.com-error_log
    CustomLog /var/log/apache2/mercurial.example.com-access_log combined

    HostnameLookups Off
    UseCanonicalName Off
    ServerSignature On

    #Include /etc/apache2/custom/mercurial.conf

    ScriptAlias /cgi-bin/ "/srv/www/vhosts/mercurial.example.com/cgi-bin/"
    ScriptAliasMatch ^/hg(.*) "/srv/www/vhosts/mercurial.example.com/cgi-bin/hgwebdir.cgi$1"

    <Directory "/srv/www/vhosts/mercurial.example.com/cgi-bin">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
    </Directory>

    <Directory "/srv/www/vhosts/mercurial.example.com/http">
    Options FollowSymLinks
    AllowOverride AuthConfig
    DirectoryIndex /hg
    Order allow,deny
    Allow from all
    </Directory>

    </VirtualHost>

  11. Create a mercurial.example.com-ssl.conf file for https and authentication
    # vi /etc/apache2/vhosts.d/mercurial.example.com-ssl.conf

    <IfDefine SSL>
    <IfDefine !NOSSL>

    <VirtualHost *:443>
    ServerName mercurial.example.com:443
    ServerAlias hg.example.com:443
    ServerAlias mercurial:443
    ServerAlias hg:443

    DocumentRoot "/srv/www/vhosts/mercurial.example.com/https"
    ErrorLog /var/log/apache2/mercurial.example.com-ssl-error_log
    CustomLog /var/log/apache2/mercurial.example.com-ssl-access_log combined

    HostnameLookups Off
    UseCanonicalName Off
    ServerSignature On

    Include /etc/apache2/custom/mercurial.conf

    SSLEngine on
    SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
    SSLCertificateFile /etc/apache2/ssl.crt/server.crt
    SSLCertificateKeyFile /etc/apache2/ssl.key/server.key

    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
    </Files>

    ScriptAlias /cgi-bin/ "/srv/www/vhosts/mercurial.example.com/cgi-bin/"
    ScriptAliasMatch ^/hg(.*) "/srv/www/vhosts/mercurial.example.com/cgi-bin/hgwebdir.cgi$1"

    <Directory "/srv/www/vhosts/mercurial.example.com/cgi-bin">
    SSLOptions +StdEnvVars
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
    </Directory>

    SetEnvIf User-Agent ".*MSIE.*" \
    nokeepalive ssl-unclean-shutdown \
    downgrade-1.0 force-response-1.0

    <Directory "/srv/www/vhosts/mercurial.example.com/https">
    Options FollowSymLinks
    AllowOverride AuthConfig
    DirectoryIndex /hg
    Order allow,deny
    Allow from all
    </Directory>

    CustomLog /var/log/apache2/ssl_request_log   ssl_combined
    </VirtualHost>

    </IfDefine>
    </IfDefine>

  12. Test your configuration and reload/restart apache
    # apache2ctl configtest
    # rcpache2 reload

One thought on “Mercurial Server Install for SLES

Leave a Reply