Clone wiki

hGate / install

[ English ] [ Русский ]

hGate installation instuctions (for Linux system, based on Debian)

These instructions are tailored for systems based on Debian, e.g. Ubuntu. You may have to tweak these instructions for other distributions. (Please submit and changes necessary for other distributions to bugtracker or via email toshedarhome@gmail.com.)

hGate requires an installed version of mercurial.

Installation of hGate proceeds via the following steps:

  1. Install Django
  2. Install hGate
  3. Configure hGate
  4. Configure access rights
  5. Make sure, it works

Installing Django (1.2 or later)

This step is required if Django is not installed yet. For installation from repository please run next command.

$ sudo apt-get install python-django

If your want to install the latest version - follow the instructions here The Django Book

Installing hGate

Variant 1. Installing from repository

Go to the directory where you want to install hGate. E.g. /var/www

$ cd /var/www/

Make a clone of the latest version from the hgate source repository

$ hg clone https://bitbucket.org/shedar/hgate/

Variant 2. Installing from archive

Download an archive in a suitable format from the project page.

Extract the archive files to an appropriate directory.

Configuring hGate

Alter the following settings in the file settings.py:

  • HGWEB_CONFIG - defines the path to the hgwebdir configuration
  • REPOSITORIES_ROOT - path to the storage of repositories. New repositories and groups will be created in this directory
  • AUTH_FILE - file with users authorization data for accessing repositories
  • AUTH_TYPE - authorization type. Only basic for now
  • MEDIA_URL - prefix for files and scripts. If you are installing hGate as a subdomain, then leave this empty; if into a directory, then set proper value. e.g. if you want http://example.com/hgate , then the value should be "/hgate".

Web server configuration

You can use apache with mod_python or any other web server which supports FastCGI.

Variant 1. Using Apache2 and mod_python Install apache and mod_python

$ sudo apt-get install apache2 libapache2-mod-python

Enable mod_python

$ sudo a2enmod python

You may install hGate as a subdomain or into a directory. Choose your variant.

Installation as a subdomain

Create a virtual host for hGate in Apache. If you installed hGate into the /var/www, then virtual host configuration is as follows:

<VirtualHost *>
        ServerName hgate.example.com
        DocumentRoot /var/www/hgate

        <Location "/">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE hgate.settings
                PythonDebug Off
                PythonPath "['/var/www/hgate','/var/www/hgate/hgate'] + sys.path"
        </Location>

</VirtualHost>

Installing into a subdirectory

Add Location to your Apache configuration for hGate:

        <Location "/hgate/">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE hgate.settings
                PythonOption django.root /hgate
                PythonDebug Off
                PythonPath "['/var/www/hgate','/var/www/hgate/hgate'] + sys.path"
        </Location>

After making these configuration changes, restart apache.

$ sudo /etc/init.d/apache2 restart

Configuring access rights

As far as hGate changes parameters of repositories and users, so next access rights needed for user hGate works under:

  • Mercurial configuration file, defined as HGWEB_CONFIG - rw
  • Repsitories root directory, defined as REPOSITORIES_ROOT, and it`s subdirerctories - rw
  • Authorization file, defined as AUTH_FILE - rw

    hGate works under a certain user and certain group. You can provide access rights for the above files and folders in the following way:
  • file/dir belongs to the same user hGate works under. Files/dir are set access rights to read/write for owner;
  • file/dir belongs to the same group hGate works under. Files/dir are set access rights to read/write for group;
  • set access rights read/write/execute for all users (not recommended!).

If hGate works under apache, which by default is run by www-data user, then set access rights of configuration files/directories for this user, e.g. next way:

$ sudo chown www-data:www-data /etc/mercurial/hgweb.config
$ sudo chown -R www-data:www-data /home/hg
$ sudo chown www-data:www-data /etc/mercurial/users


When user-owner or group-owner is set, you need to set read/write access for files and read/write/execute access for directories:

  • changing access rights of owner (recommended):
$ sudo chmod u+r+w /etc/mercurial/hgweb.config
$ sudo chmod -R u+r+w+x /home/hg
$ sudo chmod u+r+w /etc/mercurial/users
  • or changing access rights for group:
$ sudo chmod g+r+w /etc/mercurial/hgweb.config
$ sudo chmod -R g+r+w+x /home/hg
$ sudo chmod g+r+w /etc/mercurial/users
  • or give read/write/execute for all (not recommended!):
$ sudo chmod 777 /etc/mercurial/hgweb.config
$ sudo chmod -R 777 /home/hg
$ sudo chmod 777 /etc/mercurial/users

Testing

If you installed hGate as a subdomain, then try to open a url like http://hgate.example.com/ where example.com - your domain, hgate - subdomain.
If you installed hGate into a subdirectory, then try a url like http://example.com/hgate/ where example.com - your domain, hgate - directory where hGate is located.

Upon success you will see the main page:
hgate main page

Updated