HowTo: RedMine with Subversion in Ubuntu 10.10

The following instructions have been cobbled together from various sources (plus my own random thoughts) and has FINALLY got me a working Redmine installation under Ubuntu 10.10.

I’m far from a Linux/Ubuntu guru so I’d welcome any input/suggestions/corrections to make it better and to correct any mistakes.

Here goes:

I know that Redmine can be installed as a package in Ubuntu, but it doesn’t appear to be the latest version (1.1.0 at the time of writing). So I’m taking the longer route to get it working, as I couldn’t get it to configure the way I want. It does have the advantage that I’m using the very latest version straight from RubyForge.

Firstly install all the required libraries:

sudo 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

Now create the database:

sudo mysql -u root -p

This will prompt you for the password for the ‘root’ MySql account you created when you installed MySql.

The prompt will change to:


Now enter the following, line by line:

CREATE DATABASE redmine character SET utf8;

CREATE user 'redmine'@'localhost' IDENTIFIED BY 'my_password';

GRANT ALL privileges ON redmine.* TO 'redmine'@'localhost';

Now we’re going to download the latest version of Redmine from RubyForge:

cd /usr/share

sudo wget

Unpack the archive:

sudo tar xvfz redmine-1.1.0.tar.gz

And tidy things up a little:

sudo rm redmine-1.1.0.tar.gz
sudo mv redmine-1.1.0 redmine

We also need to adjust some of the ownership of the folders

sudo chown -R root:root /usr/share/redmine

However, we need to make sure that a particular file is set to www-data as owner. This is because Passenger runs as the user that owns this file.

sudo chown www-data /usr/share/redmine/config/environment.rb

We'll create a symbolic link from the main website home back to our actual Redmine application directory:

sudo ln -s /usr/share/redmine/public /var/www/redmine

Now configure the database:

sudo cp redmine/config/database.yml.example redmine/config/database.yml

Run nano or your favourite editor and edit it to the following:

sudo nano redmine/config/database.yml
    adapter: mysql
    database: redmine
    host: localhost
    username: redmine
    password: my_password
    encoding: utf8

Install RubyGem:

sudo wget
sudo tar xvfz rubygems-1.3.7.tgz
sudo rm rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo ruby setup.rb

Install Rails + Rack: (note the version numbers are IMPORTANT, Redmine is VERY picky over which versions it will & won't run with!)

sudo gem install rails -v=2.3.5
sudo gem install rack -v=1.0.1
sudo gem install mysql
sudo gem install i18n -v=0.4.2

Configure Redmine:

cd /usr/share/redmine
sudo rake generate_session_store
sudo RAILS_ENV=production rake db:migrate
sudo RAILS_ENV=production rake redmine:load_default_data
sudo chown -R www-data:www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

Test Redmine:

sudo ruby script/server webrick -e production

If you enter your webaddress:http://my_website:3000 you should see the Redmine homepage.

If all is well at this point, we can now configure Passenger to make sure it launches when Apache runs.

Install & Configure Passenger:

sudo gem install passenger
sudo passenger-install-apache2-module

Passenger will run & compile the source code into the module for Apache.

Now use nano or your favourite editor to create the loader:

sudo nano /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/apache2/

Make a link to make the module enabled:

sudo ln -s /etc/apache2/mods-available/passenger.load /etc/apache2/mods-enabled/passenger.load

Now create a configuration file for Passenger:

sudo nano /etc/apache2/mods-available/passenger.conf
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.2
PassengerRuby /usr/bin/ruby1.8

Now configure Apache for our new site:

sudo nano /etc/apache2/sites-available/mysite
<VirtualHost *:80>
    DocumentRoot /var/www/redmine
    LogLevel warn
    ErrorLog /var/log/apache2/redmine_error
    CustomLog /var/log/apache2/redmine_access combined
    <Directory /var/www/redmine>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
        RailsBaseURI /redmine
        PassengerResolveSymlinksInDocumentRoot on

We also need to tell Apache how to configure Passenger:

sudo nano /etc/apache2/apache2.conf

Add the following line at the end of the file:

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

Finally, enable the site:

sudo ln -s /etc/apache2/sites-available/mysite /etc/apache2/sites-enabled/mysite

Remove the default site:

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

Make sure the Passenger module is enabled:

sudo a2enmod passenger

And, restart Apache:

sudo /etc/init.d/apache2 restart

Configure Subversion

We need to copy the Perl script from Redmine to somewhere it can be accessed:

sudo mkdir /usr/lib/perl5/Apache/Authn

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

Create the site description for our Subversion HTTP access:

sudo nano /etc/apache2/sites-available/svn

Enter the following details:

# /svn location for users
PerlLoadModule Apache::Authn::Redmine
<Location /svn>
    DAV svn
    SVNParentPath "/var/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
        Allow from localhost
        Satisfy any
    # write access
        Require valid-user

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

Now setup our repository directory:

sudo mkdir -p /var/svn
sudo chown -R www-data:www-data /var/svn
sudo chmod 0750 /var/svn

Now you need to log into Redmine, then select Administration->Settings->Repositories.

Tick the 'Enable WS for repository management' option and then click 'Generate a key'. Remember to click 'Save' to store all the settings.

Now run the following code, entering the data that is correct for your site & key:

ruby /usr/share/redmine/extra/svn/reposman.rb --redmine --svn-dir /var/svn --owner www-data --url --verbose --key=my_api_key

This should query your Redmine installation and attempt to create a project directory under the repository root you specified. As this isn't being run as root this will fail, but that's fine.

Now set this up so it'll automatically check for any new projects & create any necessary repositories:

sudo crontab -e

Add the following at the end:

*/10 * * * * ruby /usr/share/redmine/extra/svn/reposman.rb --redmine --svn-dir /var/svn --owner www-data --url --verbose --key=my_api_key

Now enable the site:

sudo ln -s /etc/apache2/sites-available/svn /etc/apache2/sites-enabled/svn

Installing RMagick

sudo apt-get install imagemagick libmagick9-dev
sudo gem install rmagick

Finally, restart Apache

sudo /etc/init.d/apache2 restart

And that's all...finally! 🙂



2 thoughts on “HowTo: RedMine with Subversion in Ubuntu 10.10

  1. Hey, really good article!
    Now i have my redmine install working perfect 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s