Redmine

From SME Server
Revision as of 15:20, 23 October 2008 by Thf (talk | contribs)
Jump to navigation Jump to search

Redmine is a flexible project management web application. Written using the Ruby on Rails framework, it is cross-platform and cross-database.

This is a Howto of how I went about getting a basic installation of Redmine going on my SME server. I have now been using it for a number of months and am quite happy with it. As a matter of fact, I converted my existing Trac project environments to Redmine and have been using Redmine exclusively since.

Ruby On Rails

Redmine is a Ruby On Rails application. Install it using the Howto RubyOnRails.

Redmine User

The Redmine webservice needs a user to operate under and it needs an ability to access email for some of its services. The easiest thing to do is to create a new user 'redmine' using your server-manager panel. This users also needs access to a login shell.

Redmine Installation

The installation instructions for redmine are listed at http://www.redmine.org/wiki/redmine/RedmineInstall.

I chose the checkout option and installed from a shell as follows:

Become root:

 su -

Switch to user redmine:

 su - redmine
 cd /opt
 svn checkout http://redmine.rubyforge.org/svn/trunk redmine

Create the Redmine database

Again the installation instructions are on http://www.redmine.org/wiki/redmine/RedmineInstall. I found it easiest to create the database using PHPMyAdmin. The database is a called 'redmine' with an appropriate password and accessible by the user you created above.

Connecting Redmine to the database

To setup Redmine to use the database you just created, goto:

 cd /opt/redmine/config

then copy the database example config file:

 cp config/database.yml.example config/database.yml

and edit new database.yml file to list your database name, username and database password.

Create the database structure

Setup the database as per the installation instructions as:

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

Start the server

You can now test start your server with the command:

 ruby script/server -e production

and you should be able to browse your Redmine environment on:

 http://yourservername:3000/

Accessing Redmine through your main webserver

To access Redmine through the main webserver, I created the following custom template in

 mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
 cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
 vim 95redmine
  # Redmine proxy to connect to mongrel process on port 2555

  ProxyPass        /redmine http://localhost:2555
  ProxyPassReverse /redmine http://localhost:2555

  <Location /redmine>
    Order Deny,Allow
    Deny from All
    Allow from 127.0.0.1 10.1.0.0/255.255.255.0
  </Location>

Expand the template and restart the http server.

Now Redmine can be accessed through http://servername/redmine

As you can see from the above, I only allowed access from the local network.

Then Redmine itself needs to be reconfigured as follows to allow this path prefix for the application:

 su - redmine
 cd  /opt/redmine/config
 vim environment.rb

And as the last line in the file add:

ActionController::AbstractRequest.relative_url_root = "/redmine"

Note that the port number used for the Redmine proxy above (2555) is configured in the start/stop script below.

Starting and stopping the Redmine server

In /etc/init.d, create the following script 'redmine':

#!/usr/bin/env ruby

require "fileutils"
include FileUtils

require "rubygems"

begin
  gem 'mongrel'
rescue => e
  puts "Error: daemon mode of redmine requires mongrel installed"
  exit 1
end

def redmine_path
  "/opt/redmine"
end

def redmine_user
  "redmine"
end

command = ARGV.shift

case command
when 'start'
  system "su - #{redmine_user} -c 'cd #{redmine_path}; mongrel_rails start -d -e production -p 2555'"
  exit 0
when 'stop'
  system "cd #{redmine_path}; mongrel_rails stop"
  system "rm -f #{redmine_path}/log/mongrel.pid"

  exit 0
else
  p "Usage: /etc/init.d/redmine start|stop"
  exit 1
end

Then create the links to start and stop automatically:

 cd /etc/rc7.d
 ln -s ../init.d/redmine S99redmine 
 TODO: the link to stop the server at shutdown

Upgrading Redmine

If you used the checkout method of installing, you can upgrade your Redmine installation with the following commands:

As root:

 su -
 /etc/init.d/redmine stop
 su - redmine

As redmine:

 cd /opt/redmine
 svn update
 rake db:migrate RAILS_ENV="production"
 exit

As root:

 /etc/init.d/redmine start

Importing Trac into Redmine

I has some success in importing existing Trac environments into Redmine as per the instructions on http://www.redmine.org/wiki/redmine/RedmineMigrate.

The biggest trouble in that process was getting hold of the right sqlite-ruby library for the migration script to access the Trac database (unfortunately I don't remember how I fixed that).

Additional information

More information about Redmine can be found on http://www.redmine.org

More information on the SME Subversion Web Panel can be found in http://wiki.contribs.org/Subversion.