HowTo configure Redmine for advanced git integration » History » Version 10
Hallison Vasconcelos Batista, 2011-12-14 21:21
Addition of the git-webby as alternative git-http-backend
1 | 1 | Felix Schäfer | h1. HowTo configure Redmine for advanced git integration |
---|---|---|---|
2 | |||
3 | 3 | Felix Schäfer | {{>TOC}} |
4 | |||
5 | 1 | Felix Schäfer | h2. Scope |
6 | |||
7 | This HowTo explains how to serve git repositories on apache through the http-based "git-smart-http protocol":http://progit.org/2010/03/04/smart-http.html 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. |
||
8 | |||
9 | 7 | Felix Schäfer | This HowTo is mainly written from memory and was conducted on a setup which was already serving [[Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl|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 :-) You can also "drop me a line":/users/3866. |
10 | |||
11 | Another option to integrate grack with redmine is the "modified grack+redmine plugin":http://github.com/friflaj/redmine_grack or "any other grack modified for redmine":http://github.com/search?q=grack&type=Everything&repo=&langOverride=&start_value=1, though those ones lack documentation and I haven't tried them, so I can't say much about those. |
||
12 | 1 | Felix Schäfer | |
13 | h2. Prerequisites |
||
14 | |||
15 | * Apache with mod_perl (access control) |
||
16 | * git (version at least 1.6.6) |
||
17 | * A way to serve git-smart-http |
||
18 | ** mod_cgi (or mod_cgid) if you want to use the stock "git-http-backend":http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html |
||
19 | 10 | Hallison Vasconcelos Batista | ** a rack server if you want to use "grack":http://github.com/schacon/grack (basically a rack wrapper around the right git commands) or |
20 | "git-webby":http://git.io/BU7twg (another implementation based on grack but written in Sinatra). |
||
21 | 1 | Felix Schäfer | |
22 | 6 | Felix Schäfer | 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 (skip the [[HowTo_configure_Redmine_for_advanced_git_integration#Install-grack|grack installation]] part and get your install with the git-http-backend going (the "git-http-backend manpage":http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html has some examples), when that's done go on with the [[HowTo_configure_Redmine_for_advanced_git_integration#Access-control|access control]] part). |
23 | 2 | Felix Schäfer | |
24 | h2. Install grack |
||
25 | 1 | Felix Schäfer | |
26 | 3 | Felix Schäfer | h3. Get the sources |
27 | 2 | Felix Schäfer | |
28 | Fetch grack from its "github repository":http://github.com/schacon/grack, I checked out mine to @/var/www/git.myhost.com@: |
||
29 | |||
30 | 5 | Holger Just | <pre><code class="bash">git clone http://github.com/schacon/grack.git /var/www/git.myhost.com</code></pre> |
31 | 1 | Felix Schäfer | |
32 | 3 | Felix Schäfer | h3. Configuration |
33 | |||
34 | 2 | Felix Schäfer | 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): |
35 | |||
36 | <pre><code class="ruby">$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib') |
||
37 | |||
38 | use Rack::ShowExceptions |
||
39 | |||
40 | require 'lib/git_http' |
||
41 | |||
42 | config = { |
||
43 | :project_root => "/var/git/git.myhost.com", |
||
44 | :git_path => '/usr/libexec/git-core/git', |
||
45 | :upload_pack => true, |
||
46 | :receive_pack => true, |
||
47 | } |
||
48 | |||
49 | run GitHttp::App.new(config)</code></pre> |
||
50 | 1 | Felix Schäfer | |
51 | 3 | Felix Schäfer | h3. Integrate with Apache |
52 | |||
53 | You could obviously use any rack server you like at this point, but the access control mechanism @Redmine.pm@ is written for apache with mod_perl, so you will at least need to reverse proxy your rack server through apache. My rack server of choice is "passenger":http://modrails.com/ (solid performance, apache module, mostly simple configuration) and it is already configured on my system. As passenger installation and configuration is not within the scope of this HowTo, please refer to the "passenger documentation":http://modrails.com/documentation.html or to the passenger installation guide from your distribution. |
||
54 | |||
55 | 2 | Felix Schäfer | 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! |
56 | |||
57 | The last step is to configure an apache vhost to serve the application: |
||
58 | |||
59 | <pre><code class="apache"><VirtualHost yo.ur.i.p:80> |
||
60 | ServerName git.myhost.com |
||
61 | |||
62 | ServerAdmin root@myhost.com |
||
63 | DocumentRoot "/var/www/git.myhost.com/public" |
||
64 | |||
65 | <Directory "/var/www/git.myhost.com/public"> |
||
66 | Options None |
||
67 | AllowOverride None |
||
68 | Order allow,deny |
||
69 | Allow from all |
||
70 | </Directory> |
||
71 | </VirtualHost></code></pre> |
||
72 | |||
73 | 1 | Felix Schäfer | 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. |
74 | 10 | Hallison Vasconcelos Batista | |
75 | h2. Install git-webby |
||
76 | |||
77 | Follow the instructions available in "repository page":http://git.io/BU7twg that use basically the same instructions described above. |
||
78 | 3 | Felix Schäfer | |
79 | h2. Access control |
||
80 | |||
81 | You now have a working git server, albeit with no access control. Currently, the shipped perl module for access control @Redmine.pm@ (in @extra/svn/@ in your redmine directory) does not support access control for the git-smart-http protocol, the patch in #4905 aims to implement that. |
||
82 | |||
83 | h3. Applying the patch |
||
84 | |||
85 | Download the latest (or better: correct) version of the patch from #4905 to your redmine directory. In the redmine directory, apply the patch: @patch -p1 < the-patch-file.patch@ should work (if it tells you stuff about being unable to apply a hunk, the patch is incompatible with your @Redmine.pm@ version, if it says other stuff, try @patch -p0 < the-patch-file.patch@, if it still borks, ask for advice on #4905). |
||
86 | |||
87 | 8 | Felix Schäfer | -You will possibly still need to edit the file from here, because the current version of the patch only works for repositories served from @http://git.myhost.com/git/myrepo@ though the above example uses @http://git.myhost.com/myrepo@.- This step isn't needed anymore, the patch has been updated to take the information from the @Location@ block from apache into account. |
88 | 3 | Felix Schäfer | |
89 | h3. Configuring Apache |
||
90 | |||
91 | 9 | Loren Sands-Ramshaw | You now have to make Apache aware of your new authentication module (if you already had done this step for subversion integration, you can go to the @Location@ directives directly). Copy or link @Redmine.pm@ (from your @extra/svn/@ directory) to @/usr/lib/perl5/Apache/Redmine.pm@ (ubuntu) or wherever your distribution puts its apache perl modules (e.g. gentoo puts them in @/usr/lib64/perl5/vendor_perl/5.8.8/Apache/@). |
92 | 3 | Felix Schäfer | |
93 | Having done that, reload apache to make sure everything in the patching phase went well (if not, remove the link or the file create in the step just before and restart apache to get apache back up, try to find the error in your Redmine.pm file). Now edit your vhost configuration to look somewhat like (same as above but with more stuff): |
||
94 | |||
95 | <pre><code class="apache"><VirtualHost yo.ur.i.p:80> |
||
96 | ServerName git.myhost.com |
||
97 | |||
98 | ServerAdmin root@myhost.com |
||
99 | DocumentRoot "/var/www/git.myhost.com/public" |
||
100 | |||
101 | PerlLoadModule Apache::Redmine |
||
102 | |||
103 | <Directory "/var/www/git.myhost.com/public"> |
||
104 | Options None |
||
105 | AllowOverride None |
||
106 | Order allow,deny |
||
107 | Allow from all |
||
108 | </Directory> |
||
109 | |||
110 | <Location "/"> |
||
111 | AuthType Basic |
||
112 | AuthName "Redmine git repositories" |
||
113 | Require valid-user |
||
114 | |||
115 | PerlAccessHandler Apache::Authn::Redmine::access_handler |
||
116 | PerlAuthenHandler Apache::Authn::Redmine::authen_handler |
||
117 | |||
118 | ## for mysql |
||
119 | RedmineDSN "DBI:mysql:database=databasename;host=my.db.server" |
||
120 | ## for postgres |
||
121 | # RedmineDSN "DBI:Pg:dbname=databasename;host=my.db.server" |
||
122 | ## for SQLite3 |
||
123 | # RedmineDSN "DBI:SQLite:dbname=database.db" |
||
124 | |||
125 | RedmineDbUser "redmine" |
||
126 | RedmineDbPass "password" |
||
127 | RedmineGitSmartHttp yes |
||
128 | </Location> |
||
129 | </VirtualHost></code></pre> |
||
130 | |||
131 | Reload your apache, and everything should be good and well :-) |
||
132 | |||
133 | h2. Known issues |
||
134 | |||
135 | Currently none… |