Redmine installation + SVN repository configuration and integration

Redmine installation + SVN repository configuration and integration

Redmine is a free (free as freedom) system to manage projects and track bugs. It’s written in Ruby on Rails. Its source code is distributed under the GNU GPL license.

We’ve been using Redmine to manage projects for more than two years. During this time, the system had accumulated 80 thousands projects and some fifty members.

Installation of Redmine on Ubuntu 10.04 Server

Put the required packages:

aptitude install redmine redmine-mysql

The installation scripts offer to configure the package:

Redmine Installation + SVN repository configuration and integration

Choose from which database Redmine will run:

Redmine Installation + SVN repository configuration and integration

Enter MySQL administrator password and the access password to the database of the Redmine:

Redmine Installation + SVN repository configuration and integration

Redmine Installation + SVN repository configuration and integration

If after this the comparison of tables is exhibited in latin1_swedish_ci (or any other encoding different from utf8_general_ci) add to /etc/mysql/my.cfg section the mysqld collation-server = utf8_general_ci and character-set-server = utf8 directives. Then completely remove the database and create a new Redmine database with comparison to utf8_general_ci. Now we develop a new Redmine base:

# cd /usr/share/redmine/
/usr/share/redmine# rake db:migrate RAILS_ENV="production" 

After that, we will have all the tables in utf8_general_ci and Cyrillic will cause no problems.

Configuring mod-passenger

Mod Passenger is used to provide a connection between Apache web server and applications written in Ruby On Rails.
With its help Apache can act as a Web server for ROR applications.

Installation of packages:

aptitude install libapache2-mod-passenger

Load module Apache:

a2enmod passenger

Configure the vhost for Redmine:

vim /etc/apache2/sites-enabled/
<VirtualHost *:80>
  DocumentRoot /usr/share/redmine/public
  # Without PassengerDefaultUser www-data Redmine can't load files to server
  PassengerDefaultUser www-data
  <Directory /usr/share/redmine/public>
    Orderallow,denyAllow from all
    RailsEnv production

After that Redmine should be available at

Setting of SVN repositories and their integration with Redmine

Redmine is capable to display changes in the repository, to keep a log of activity, draw graphics on the number of the comets in the repository. Also Redmine can manage repository access rights on the basis of its users and their subscriptions to projects as well as automatically create a repository for new projects.

Install the required packages:

aptitude install subversion 
aptitude install libapache2-svn libapache-dbi-perl libapache2-mod-perl2 libdbd-mysql-perl libdigest-sha1-perl

Load all required Apache modules:

a2enmod dav
a2enmod dav_svn
a2enmod perl

Then add one line in the configuration of the module:

vim /etc/apache2/mods-enabled/perl.load
LoadModule perl_module /usr/lib/apache2/modules/
PerlLoadModule Apache::Redmine

To allow users to log in to svn topic under the same credentials that in Redmine, create a symbolic link to the script (you can simply copy it, but it's better to create a link):

ln -s /usr/share/redmine/extra/svn/ /usr/lib/perl5/Apache/

Configure vhost for svn:

vim /etc/apache2/conf.d/
<VirtualHost *:80>
        <Location /svn>
                 # plugin module dav svnDAV svn
                 # configure authorization login / passwordAuthType Basic
                 AuthName redmine
                 Require valid-user
                 # plugin script
                 PerlAccessHandler Apache::Authn::Redmine::access_handler
                 PerlAuthenHandler Apache::Authn::Redmine::authen_handler
                 # setup database connection
                 RedmineDSN "DBI:mysql:database=redmine_default;host=localhost" 
                 # login and password to access Redmine database
                 RedmineDbUser "redmine" 
                 RedmineDbPass "password" 
        <Location /svn-private>
                  DAV svn
                  SVNParentPath"/var/svn"Orderdeny,allowDeny from all# only allow reading orders
                  <Limit GET PROPFIND OPTIONS REPORT>
                  Allow from redmine_server_ip

svn-private is required to allow Redmine the access the repository without authorization. This will let completely automate the creation and connectivity of a repository to the new project. It also can be used on your servers to update the source code without having to login.

Now the output dialog of authorization should appear at

Automatic creation of SVN repositories for projects

For this task, there is a script /usr/share/redmine/extra/svn/reposman.rb. At startup it checks the projects created by Redmine and existing svn repository. And if there is a project lacking repository - it will create it. To make it work you need to register reposman.rb launch in crontab:

*/5 * * * * /usr/share/redmine/extra/svn/reposman.rb --redmine --key=ключ --svn-dir /var/svn --owner www-data --url --verbose

Description of the script arguments:

  • --key — API key. In Redmine Administration → Settings → Repository → API key. Select Generate a key and copy it into the script.
  • --redmine — host on which redmine hangs.
  • --svn-dir — path to svn.
  • --owner — the owner of the repository.
  • --url — url to svn (svn-private is required to give redmine an access to the repositories without authorization).

Well, all setup is completed. Now you can try to create a project and after a while a repository for it will be created automatically. Then add participants to the project and try to log in to the repository using their credentials.