This is a tutorial for installing redmine on Ubuntu 8.04 with SVN and Git integration (managed by Gitosis and a redmine gitosis plugin).

UPDATE #1 – 2011-04-23: New Tutorial for Redmine with Git and Gitosis on Ubuntu 11.04:http://www.x2on.de/2011/04/23/tutorial-redmine-with-git-and-gitosis-on-ubuntu-11-04/

1. Install redmine

Get recent trunk version from github (currently 1.02)

1
2
3
4
apt-get install git-core
mkdir /var/www
cd /var/www
git clone git://github.com/edavis10/redmine.git

Install packages

1
apt-get install ruby ruby1.8-dev libgemplugin-ruby libgemplugin-ruby1.8  mysql-server apache2-mpm-prefork wget libruby-extras libruby1.8-extras rails subversion rake apache2-prefork-dev libapache-dbi-perl libapache2-mod-perl2 libdigest-sha1-perl libapache2-svn libmysqlclient15-dev build-essential libcurl4-openssl-dev cron

Create database

1
2
3
4
5
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';

Configure Database Settings

1
2
cp redmine/config/database.yml.example redmine/config/database.yml
nano redmine/config/database.yml
1
2
3
4
5
6
7
production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: 47w8t2938qfge2
  encoding: utf8

Install Rubygem (Ubuntu 8.04 has an older version)

1
2
3
4
5
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
tar xvfz rubygems-1.3.7.tgz
cd rubygems-1.3.7
ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/bin/gem

Install Rails + Rack

1
2
3
gem install rails -v=2.3.5
gem install rack -v=1.0.1
gem install mysql

Configure redmine

1
2
3
4
5
6
cd /var/www/redmine
chown -R www-data:www-data files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets
rake generate_session_store
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

Test redmine

1
ruby script/server webrick -e production

Now you can check http://my_domain.com:3000 if everything works

2. Apache Integration

Install passenger (Modify version numbers if needed)

1
2
3
gem install passenger
echo "LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.0/ext/apache2/mod_passenger.so" > /etc/apache2/mods-available/passenger.load
ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load
1
nano /etc/apache2/mods-available/passenger.conf
1
2
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.0
PassengerRuby /usr/bin/ruby1.8

Configure Apache

1
nano /etc/apache2/sites-available/my_domain
1
2
3
4
5
6
7
8
9
10
11
12
13
ServerName my_domain.com

DocumentRoot /var/www/redmine/public

ServerAdmin user@example.com
LogLevel warn
ErrorLog /var/log/apache2/redmine_error
CustomLog /var/log/apache2/redmine_access combined

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
1
nano /etc/apache2/apache2.conf

Add this at the end of the file:

1
Include /etc/apache2/mods-available/passenger.conf

Activate your site

1
ln -s /etc/apache2/sites-available/my_domain /etc/apache2/sites-enabled/my_domain

Remove default entry

1
rm /etc/apache2/sites-enabled/000-default

Restart Apache and it should work

1
/etc/init.d/apache2 restart

3. Subversion integration

1
2
ln -s /var/www/redmine/extra/svn/Redmine.pm /usr/lib/perl5/Apache/Redmine.pm
nano /etc/apache2/sites-available/svn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 # /svn location for users
 PerlLoadModule Apache::Redmine

   DAV svn
   SVNParentPath "/var/repos/svn"
   Order deny,allow
   Deny from all
   Satisfy any

   PerlAccessHandler Apache::Authn::Redmine::access_handler
   PerlAuthenHandler Apache::Authn::Redmine::authen_handler
   AuthType Basic
   AuthName "Redmine SVN Repository"

   #read-only access

      Require valid-user
      Allow from my_domain.com
      Allow from localhost
       Satisfy any

   # write access
     Require valid-user

   ## Mysql-Settings
   RedmineDSN "DBI:mysql:database=redmine;host=localhost"
   RedmineDbUser "redmine"
   RedmineDbPass "my_password"

#Security:

      Order deny,allow
      Allow from localhost
      Allow from my_domain.com
      Deny from all
1
2
3
4
ln -s /etc/apache2/sites-available/svn /etc/apache2/sites-enabled/svn
mkdir -p /var/repos/svn
chown -R www-data:www-data /var/repos
chmod 0750 /var/repos/svn

Go to Administration – Settings – Repositories on your redmine site and enable “WS for repository management”. Then generate an API key.

Test the automatic generation:

1
ruby /var/www/redmine/extra/svn/reposman.rb --redmine my_domain.com --svn-dir /var/repos/svn --owner www-data --url http://my_domain.com/svn --verbose --key=my_api_key

If everything works create an crontab for this:

1
nano /etc/cron.d/redmine
1
10 * * * * root ruby /var/www/redmine/extra/svn/reposman.rb --redmine my_domain.com --svn-dir /var/repos/svn --owner www-data --url http://my_domain.com/svn --verbose --key=my_api_key

Now you are ready to use SVN with redmine

4. Git integration

Install needed packages:

1
2
3
4
5
gem install inifile
apt-get install libnet-ssh-ruby1.8 python-setuptools
gem install lockfile
easy_install pip
pip install virtualenv

Add an user for gitosis:

1
adduser --system --shell /bin/bash --gecos 'Git Administrator' --group --disabled-password --home /opt/gitosis git

Create an ssh-key (with empty passphrase):

1
sudo -H -u git ssh-keygen -t dsa

Create an Virtual Environment for python and install gitosis:

1
2
3
4
sudo -u git virtualenv ~git/virtualenv
sudo -u git ~git/virtualenv/bin/pip install git+git://eagain.net/gitosis.git
echo "source $HOME/virtualenv/bin/activate" | sudo -u git tee -a ~git/.bashrc > /dev/null
sudo -u git cat ~git/.ssh/id_dsa.pub | sudo -H -u git ~git/virtualenv/bin/gitosis-init

Install redmine-gitosis plugin:

1
2
3
cd /var/www/redmine/
chown -R www-data:www-data /var/www/redmine
script/plugin install git://github.com/rocket-rentals/redmine-gitosis.git

Patch the plugin:

1
nano /var/www/redmine/vendor/plugins/redmine-gitosis/lib/gitosis.rb
1
2
3
4
5
6
7
8
9
10
11
require 'lockfile'
require 'inifile'
require 'net/ssh'

module Gitosis
  # server config
  GITOSIS_URI = 'git@my_domain.com:gitosis-admin.git'
  GITOSIS_BASE_PATH = '/opt/gitosis/repositories/'

  # commands
  ENV['GIT_SSH'] = SSH_WITH_IDENTITY_FILE = File.join(RAILS_ROOT, 'vendor/plugins/redmine-gitosis/extra/ssh_with_identity_file.sh')

Configure SSH:

1
2
3
mkdir /var/www/.ssh
chown -R www-data:www-data /var/www/.ssh
sudo -u www-data ssh my_domain.com

Migrate plugin:

1
rake db:migrate_plugins RAILS_ENV=production

Remove standard ssh-key and change it to the created one:

1
2
3
rm /var/www/redmine/vendor/plugins/redmine-gitosis/extra/ssh/private_key
cp ~git/.ssh/id_dsa /var/www/redmine/vendor/plugins/redmine-gitosis/extra/ssh/private_key
chown -R www-data:www-data /var/www/redmine

Test if the www-data user can read the key:

1
sudo -u www-data cat /var/www/redmine/vendor/plugins/redmine-gitosis/extra/ssh/private_key

Add the www-data user to the git group:

1
usermod -a -G git www-data

Have fun!

Source:

http://brantinteractive.com/2007/02/16/getting-the-mysql-gem-installed-on-ubuntu/ http://www.redmine.org/wiki/1/RedmineInstall http://wiki.ousli.org/index.php/Redmine_in_Ubuntu_Jaunty_9.04 http://www.redmine.org/wiki/1/HowTo_Install_Redmine_in_Ubuntu http://www.redmine.org/wiki/redmine/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl http://xdissent.com/2010/05/04/github-clone-with-redmine/ http://wiki.ubuntuusers.de/virtualenv

Sponsor

Comments