Install Redmine with automated git integration (Centos, Redhat)

I had a few days work on this one while it was supposed to be done in a hour. The problem? Lack of good documentation. There seems to be no complete tutorial on the Internet how to completely integrate git with Redmine so I figured to make one myself for you my dear reader but also a little bit for myself so I can easily find it back.

Good to know: I might have used yum but we all know that the repo’s of centos en redhad are way behind in version. Please make sure you have extra repo’s. I used:

Make sure you also use repo’s for a more updated ruby and gems. I’m going to start with the ruby install right from the bat. Please make sure your server has Apache and Mysql installed. This tutorial won’t explain that part.

Installing Ruby

Redmine works on ruby so we will start with installing ruby. You can install ruby in 2 ways.

  1. From the source
  2. Trough yum

Thoose the one you prefer I will use the yum method:
yum install ruby ruby-devel ruby-libs ruby-irb ruby-rdoc ruby-mysql

Just make sure that you have the right version of ruby. The standard repositories don’t have the later versions yet so make sure to use other repositories. I used version 1.8.5. Just make sure that you use a compatible version. You can see that here: Redmine Ruby Versions

Installing ruby-gems

Installing ruby-gems goes most of the time by hand:
tar xvf rubygems-1.3.1.tgz
cd rubygems-1.3.1
ruby setup.rb

Installing Rails

You need to install rails trough gem. But you need to make sure you install the version that Redmine likes:
gem install rails -v=2.3.5

Installing Rack

gem install rack -v=1.0.1

Installing mongrel (optional)

You won’t need to install mongrel but it makes your site run so much faster so it is recommended you install it.
gem install mongrel

Installing Redmine

Download redmine

First lets download redmine. You can download the latest version at the Redmine site. Unpack it and put it in the folder you want. I will be using “/home/redmine/redmine” as my redmine root.

Creating the database

First we need to install the database. In this tutorial we will be using mysql as database driver since it’s commonly known. Log into your mysql console and run this:
create database redmine character set utf8;
create user ‘redmine’@'localhost’ identified by ‘my_password’;
grant all privileges on redmine.* to ‘redmine’@'localhost’;

Configuring Redmine

Let’s configure Redmine now. Fist we need to copy the Redmine configure file at the right place.
cd /home/redmine/redmine
cp  config/database.yml.example config/database.yml

Now edit the config to the settings you set the database with.
adapter: mysql
database: redmine
host: localhost
username: redmine
password: my_password

Generate a session store secret

cd /home/redmine/redmine
rake config/initializers/session_store.rb

rake generate_session_store

Create the database structure

RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

Set the right permissions for the files

chown -R redmine:redmine files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets

Test Run redmine

ruby script/server webrick -p 3000 -e production

People note this is only for testrunning redmine. Don’t use it for production. Use one of the many other guides in the Redmine wiki to setup redmine to use either passenger (aka mod_rails) or mongrel to serve up your redmine.

Installing and automating Git

Now we will start automating all git processes with Redmine. This means when you make a new project it will automatically create a repository for it. Since there are already many tutorials how to do this with svn ours will be about git.

First create a directory where all git repositories will be in. Mine is located at: “/home/redmine/git_repositories”

Edit your apache

Now edit your httpd.conf to fit your settings:

PerlLoadModule Apache::Redmine

SetEnv GIT_PROJECT_ROOT /home/redmine/git_repositories/
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
<Location /git>
	RedmineGitSmartHttp yes
	DAV on

	AuthType Basic
	Require valid-user
	AuthName "Git"

	PerlAccessHandler Apache::Authn::Redmine::access_handler
	PerlAuthenHandler Apache::Authn::Redmine::authen_handler

	RedmineDSN "DBI:mysql:database=redmine;host=localhost"
	RedmineDbUser "redmine"
	RedmineDbPass "my_password"

Alias /git-private /home/redmine/git_repositories

<Location /git-private>
	Order deny,allow
	Deny from all
		Options Indexes FollowSymLinks MultiViews
		Allow from
		Allow from localhost

Maybe you already noticed. That this is completely different from the configuration the Redmine sites gives. This is because we will be using git’s git-smart-http protocol. With this you can push your repository straight to the http link. If you are a valid user. For this to work you need to make sure you git version is higher than 1.6.6. Also check all paths for this httpd config since some could be off. Just try to locate the correct files with “find / -name yourfilenamehere”.

You will need to patch your to support. this protocol. You can find the patch for here: Patch Note:please make sure this patch isn’t already committed else you might patch a already fixed file. Also use linux “patch” to patch the file.

If everything is working correctly you should be able to push to the httpd “IF” your repository exists and is setup the right way.

Setting up Auto creation and checking

Some people might want Redmine to auto create their repository when a new project is added and keep tracking the changes. For this you will need to add 2 lines to the cron:
*/1 * * * * root ruby /home/redmine/redmine/script/runner "Repository.fetch_changesets" -e production
*/1 * * * * root ruby /home/redmine/redmine/extra/svn/reposman.rb -s /home/redmine/git_repositories/ -r [external-redmine-link]:3000 -u /home/redmine/git_repositories --scm git -k [repository-key] -g redmine -o redmine --verbose >> /var/log/reposman.log

This should be all to get your redmine / git integration working if I missed something or if you get errors. Please comment. I will try to edit the tutorial and help you out where I can.

Author: Robert-Jan de Dreu

Published by


Hey, I’m Robert-Jan de Dreu. A programmer mostly focusing on the web. While using PHP and MVC I will make sure the program I’m building is well documented and structured. I use this blog to show what I made and keep reminding myself of little tasks that I have done and maybe need to do again. I live in Utrecht, The Netherlands and can be found in Affiliate4you where my job is at. I’m available for freelancing if you want me to do a project for you. Just send me a message.

17 thoughts on “Install Redmine with automated git integration (Centos, Redhat)”

  1. Hi!

    Nice guide.
    Just one thing I think instead of:
    Installing Rake
    gem install rake -v=1.0.1
    You should have
    Installing Rack
    gem install rack -v=1.0.1

    Rake is still in it’s 0.9.x series.

    And one other thing IMHO it is not a good idea in general to install software from source.

  2. @jj I agree, the problem is that you don’t always have a choice because they are hard to find for some distro’s. At the time I wrote this Redhat didn’t have any good repo’s that did support Gems so I had to install it from source.

  3. Hello there,

    you didn’t mention that you run into problems, because repoman creates bare git repos, that redmine can’t handle.


  4. Greetings,

    Thanks for the detailed instructions. Do you have any ideas if you need to patch redmin 2.0.3 file? I’m going to use this version but unfortunately apache server does not see
    RedmineGitSmartHttp directive.

    Thanks in advance.

  5. @Tron After pushing some stuff to the repo redmine should be able to handle them. The initial setup shouldn’t make it bad.

    The problem is that there still is no fix for the repoman repo’s sadly.

  6. @Vasily I’m not sure. You should ask this at redmine. I do think so because I don’t see any posts on their site that they integrated it.

  7. I got this setup working fine. But Redmine is not able to view the repository through /git-private at all. When I tried to clone the repo from the /git-private url, it cloned a bare repo though the repo had changesets. Tearing my hair out trying to figure out what the issue could be. The same repo when accessed through /git with proper authentication gives the correct repo.

  8. @Guruprasad : Try to load the git url in the browser. Does it ask you to authenticate? If it does login and try to grab the “[your-repo-url]/HEAD” file to see if the paths are working correctly.

  9. @rjd22: Till now I have been testing by allowing access to only redmine for the /git-private path. The server on which redmine is running doesn’t have a GUI to try it in a browser. Will test by allowing access to a few more IP address and open the HEAD file to dig in deeper. By default /git-private path doesn’t require authentication, so I guess it won’t prompt for the credentials. Thanks for the helpful tips. :)

  10. Hi,

    Nice tutorial!
    But when I edit the httpd.conf on Ubuntu 12.04 with apache2 it will create a server config error which prevent apache from starting.
    There is only 1 httpd.conf in apache2. Do you have any idea where to add the code for apache2?


  11. I see that httpd.conf will be included in apache2.conf for user options. So httpd.conf can be used. In that case, something is wrong with my code. See below, ofc modified for my setup.

    PerlLoadModule Apache::Redmine

    SetEnv GIT_PROJECT_ROOT /var/git/
    ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/

    RedmineGitSmartHttp yes
    DAV on

    AuthType Basic
    Require valid-user
    AuthName “Git”

    PerlAccessHandler Apache::Authn::Redmine::access_handler
    PerlAuthenHandler Apache::Authn::Redmine::authen_handler

    RedmineDSN “DBI:mysql:database=redmine_default;host=localhost”
    RedmineDbUser “MY_USERNAME”
    RedmineDbPass “MY_PASSWORD”

    Alias /git-private /var/git

    Order deny,allow
    Deny from all

    Options Indexes FollowSymLinks MultiViews
    Allow from
    Allow from localhost


  12. Thanks for the article, it helped me to get GIT partially up and running on my Redmine installation.

    I tried using reposman.rb for creating the GIT repositories, but they are not initially in a state that Redmine is able to read, and the work I had to do to make it work with Redmine after creation was not really feasible (clone the repo, add a file, commit, and push).

    Instead I ended up using this plugin to make GIt repo creation easy.

Leave a Reply