Project

General

Profile

Actions

HowTo configure Redmine for advanced git integration » History » Revision 2

« Previous | Revision 2/25 (diff) | Next »
Felix Schäfer, 2010-07-13 12:55
Install grack


HowTo configure Redmine for advanced git integration

Scope

This HowTo explains how to serve git repositories on apache through the http-based git-smart-http protocol introduced in git 1.6.6. The git-smart-http offers various advantages over ssh or git-based access: you can use redmine access control as-is, no need for extra ssh keys or whatnot, you can secure it through SSL as needed, and there's generally less problems with firewalls and https/https ports than exist with ssh and git ports. git-smart-http also doesn't have some of the drawbacks of its "dumb" predecessor, as it doesn't require any complex DAV setup.

This HowTo is mainly written from memory and was conducted on a setup which was already serving svn repositories integrated with redmine, so it might be possible that I forgot some things or take them for granted. This is a wiki page, feel free to correct or amend anything you find lacking :-)

Prerequisites

  • Apache with mod_perl (access control)
  • git (version at least 1.6.6)
  • A way to serve git-smart-http
    • mod_cgi (or mod_cgid) if you want to use the stock git-http-backend
    • a rack server if you want to use grack (basically a rack wrapper around the right git commands)

You should already have a rack server to run redmine, and that's why I chose grack as the backend and which I will describe in this tutorial. Using the stock git-http-backend should be quite straightforward though.

Install grack

My rack server of choice is passenger and it is already configured on my system. As this is not within the scope of this HowTo, please refer to the passenger documentation or to the passenger installation guide from your distribution.

Fetch grack from its github repository, I checked out mine to /var/www/git.myhost.com:

git http://github.com/schacon/grack.git /var/www/git.myhost.com

Edit the config.ru file and adapt it to your local configuration. project_root must contain the path to the directory containing your git repositories, git_path must obviously contain the path to the git, mine looks like this (on gentoo):

$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib')

use Rack::ShowExceptions

require 'lib/git_http'

config = {
  :project_root => "/var/git/git.myhost.com",
  :git_path => '/usr/libexec/git-core/git',
  :upload_pack => true,
  :receive_pack => true,
}

run GitHttp::App.new(config)

There's a little more work to do here to get passenger to work with this, you will need to create the directories public and tmp in the grack directory. Please also be aware that in the standard configuration, passenger will run the grack application with the same user and group owning the config.ru file. This user must have read- and write-access as needed to the git repositories!

The last step is to configure an apache vhost to serve the application:

<VirtualHost yo.ur.i.p:80>
    ServerName git.myhost.com

    ServerAdmin root@myhost.com
    DocumentRoot "/var/www/git.myhost.com/public" 

    <Directory "/var/www/git.myhost.com/public">
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

At this point, if you have a repository in /var/git/git.myhost.com/myrepo, you should be able to access it through http://git.myhost.com/myrepo, for example git ls-remote http://git.myhost.com/myrepo should show you some information about the repository.

Updated by Felix Schäfer over 14 years ago · 2 revisions