Installing Redmine and gitosis on a Debian root-server with MySQL

September 1st, 2011 § 0 comments § permalink

So I wanted a bugtracker with a little of everything and git integration. First of all I must admit that this wasn’t easy and I wasted some time figuring out how to get this stuff working. Since I love to see tutorials and manuals myself, I’ll share my experience.

Be aware though that Ruby on Rails consumes a lot of RAM and will not run on 128MB RAM. I had to upgrade my VPS which now runs fine with 512MB RAM. I installed Redmine 1.0.1-stable on my Debian Squeeze 6 with the MySQL backend, but not without getting serious trouble when enabling the gitosis plugin: Whenever a username in git contained a umlaut, it just threw a server error. Finally I was able to tackle down the problem with a lot of help from friends over at #bsdprojects.

WARNING: This post is not intended to provide a foolproof guide or a newbie tutorial. This is meant for someone being able to handle a full root server.

INSTALLING PACKAGES

Install the needed debian packages:

apt-get install acl apache2 apache2-mpm-prefork apache2-prefork-dev build-essential cron git-core gitosis git-daemon-run libapache-dbi-perl libapache2-mod-passenger libapache2-mod-perl2 libcurl4-openssl-dev libdigest-sha1-perl libgemplugin-ruby libgemplugin-ruby1.8 libmysqlclient15-dev libnet-ssh-ruby1.8 librmagick-ruby1.8 libruby-extras libruby1.8-extras mysql-server python-setuptools rake redmine redmine-mysql ruby ruby1.8-dev rubygems sudo wget

CONFIGURING & SETUP

MySQL

This is where I failed in the first attempt, MySQL obviously has severe problems with the encoding and a configuration change was the solution eventually. Be sure to add the following to  /etc/mysql/my.cnf before you do anything else:

[client]
default-character-set=utf8

[mysqld]
default-character-set = utf8
skip-character-set-client-handshake
character-set-server = utf8
collation-server = utf8_general_ci
init-connect = SET NAMES utf8

Now create the DB:

mysql -u root -p

CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL privileges ON redmine.* TO 'redmine'@'localhost';
quit;

Configure redmine:
vi /etc/redmine/default/database.yml

  production:
    adapter: mysql
    database: redmine
    host: localhost
    username: redmine
    password: my_password
    encoding: utf8

Installing the gems

Now comes the funny part, you need to exactly these versions or you’ll encounter strange errors:
gem install rails -v=2.3.11
gem install rack -v=1.1.0
gem install mysql
gem install -v=0.4.2 i18n
gem install inifile lockfile net-ssh

Get Redmine in place

ln -s /usr/share/redmine /var/www/redmine
chown -R www-data:www-data /var/www/redmine
chmod -R 755 /var/www/redmine
cd /var/www/redmine
rake generate_session_store
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

Apache

a2enmod passenger
vi /etc/apache2/sites-avaible/redmine

    <VirtualHost *:80>
        ServerName redmine.domain.tld
        DocumentRoot /usr/share/redmine/public
        <Directory /usr/share/redmine/public/>
                Options -MultiViews
        </Directory>
    </VirtualHost>


a2ensite redmine
/etc/init.d/apache2 reload
/etc/init.d/apache2 restart

Now your Apache should be able to handle the redmine bugtracker.

 Integrate gitosis

vi /etc/fstab

    …
    /dev/foo /  ext3  acl,errors=remount-ro 0 1
    …

reboot
sudo -H -u gitosis ssh-keygen -t dsa

Set no password, use standard path/file

sudo -u gitosis cat ~gitosis/.ssh/id_dsa.pub | sudo -H -u gitosis gitosis-init
sed -i.orig 's:/var/cache:/srv/gitosis:g' /etc/sv/git-daemon/run
sv restart git-daemon
setfacl -m user:www-data:r-x,mask:r-x ~gitosis/.ssh
setfacl -m user:www-data:r--,mask:r-- ~gitosis/.ssh/id_dsa
script/plugin install git://github.com/xdissent/redmine_gitosis.git
sudo -u www-data X_DEBIAN_SITEID=default RAILS_ENV=production rake db:migrate:plugins
/etc/init.d/apache2 restart

Point your browser to your installation, log in, go to Administration -> Plugins -> Configure Redmine Gitosis, change ‘localhost’ to your domain, change xdissent.com to your domain.

The repository

Now …

  • create a normal user
  • give him administrator access
  • logout as admin, login as user
  • create new project
  • give yourself at least ‘Developer’ role (Settings -> Members)
  • go to Settings -> Repository, choose git as SCM (this step was actually nowhere mentioned …)
  • now you’ll see a new menu (on the blue background) called ‘Repository’, click on it and follow the instruction written there.

You should be able to push your git repo to the redmine server finally.

SOURCES

MySQL + UTF-8 = Not So Obvious
TUTORIAL: REDMINE WITH GIT AND GITOSIS ON UBUNTU 11.04
GitHub Clone with Redmine