Blog Archive

Thursday, November 26, 2009

Redmine configuration on Debian lenny

Redmine on Debian 5.0 (Lenny)

Redmine is a flexible project management web application. Written using Ruby on Rails framework, it is cross-platform and cross-database. Redmine is open source and released under the terms of the GNU General Public License v2 (GPL).

The following has been compiled based on the redmine installation (or DASSmine as we call here @DASS :) experience of the author with the materials collected from various resources.

Installing requirements

First install the Ruby packages from Debian and install rails with Gem (because there was a problem with the rails version 2.1.0-6 installed thru apt-get from debian lenny repo and redmine version 0.7.x with problems like 'Activity' and 'Repository' tabs' pages not working properly):

apt-get install ruby rubygems libmysql-ruby librmagick-ruby rake
gem install rails

Note: gem list to see the list of installed packages

Versions of the packages installed on the debian server:

Package

Version

redmine

0.8.4

ruby

1.8.7.72-3

rails

2.3.2

rubygems

1.2.0-3

rake

0.8.7

passenger

2.2.2

Downloading and installing redmine

Download the latest stable release of redmine from the download page

~# mkdir /var/www/redmine

~# cd /var/www/redmine
/var/www/redmine# wget http://rubyforge.org/......../redmine-X.X.X.tar.gz
/var/www/redmine# tar xvfz redmine-X.X.X.tar.gz
/var/www/redmine# mv redmine-X.X.X/* .;rm redmine-X.X.X.tar.gz -rf
/var/www/redmine# chown www-data:www-data * . -R

Configuring redmine

Create an empty MySQL database and accompanying user named redmine with the following commands:

~# mysql -u root -p

Type the following commands in mysql shell:

mysql> create database redmine character set utf8;

mysql> create user 'redmine'@'localhost' identified by 'my_password';
mysql> grant all privileges on redmine.* to 'redmine'@'localhost';
mysql> exit

Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.

/var/www/redmine# cp config/database.yml.example config/database.yml

There is necessary complete the configuration inside database.yml

production:

adapter: mysql
database: redmine
host: localhost
username: redmine
password: XXXXXXXX
encoding: utf8
socket: /var/run/mysqld/mysqld.sock

Create the database structure, by running the following command under the application root directory:

apt-get install libopenssl-ruby1.8

rake db:migrate RAILS_ENV="production"

It will create tables and an administrator account.

Insert default configuration data in database, by running the following command:

rake redmine:load_default_data RAILS_ENV="production" 

This step is optional but highly recommended, as you can define your own configuration from scratch. It will load default roles, trackers, statuses, workflows and enumerations.

Setting up permissions:

The user who runs Redmine must have write permission on the following subdirectories: files, log, tmp (create the last one if not present).

mkdir tmp public/plugin_assets

chmod -R 755 files log tmp public/plugin_assets

Note: Our permissions are 775 on the above mentioned directories.

That's all for the basic Redmine installation. Test the installation by running WEBrick web server:

/var/www/redmine# ruby script/server -e production

Once WEBrick has started, point your browser to http://192.168.10.11:3000/. You should now see the application welcome page.

Use default administrator account to log in:

  • login: admin
  • password: admin

You can go to Admin & Settings to modify application settings.

Configuring passenger apache module

Most people don't want to start Redmine using the ruby command so we integrate Ruby and Redmine into Apache using another great product, Passenger

Passenger is a module for apache2 that allow apache runs ruby on rails apps

# apt-get install ruby1.8-dev

# apt-get install make
# gem install passenger

Go to the passenger apache2 module installation

# apt-get install build-essential

# apt-get install apache2-prefork-dev
# cd /var/lib/gems/1.X/gems/passenger-X.X.X/
/var/lib/gems/1.X/gems/passenger-X.X.X# bin/passenger-install-apache2-module

Configuring Apache

In /etc/apache2/mods-available/passenger.load we will add next line

LoadModule passenger_module /usr/lib/gems/1.X/gems/passenger-X.X.X/ext/apache2/mod_passenger.so

We have to edit the conf of the passenger apache2 module in /etc/apache2/mods-available/passenger.conf

PassengerRoot /usr/lib/gems/1.X/gems/passenger-X.X.X

PassengerRuby /usr/bin/ruby1.X

And now we active the module

# a2enmod passenger

# a2enmod rewrite

Apache configuration for redmine web app:

# Configuration for redmine

# /etc/apache2/conf.d/redmine

Alias /redmine /var/www/redmine/public
SetEnv RAILS_ENV production
<Directory /var/www/redmine/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

Configuration of /var/www/redmine/config/environment.rb:

ENV['RAILS_ENV'] ||= 'production'

Note: It refers to /var/www/redmine/public and not /var/www/redmine. If you use the wrong directory, the AllowOverride directive won't work. It has to work because Redmine uses an .htaccess file in /var/www/redmine/public. As our Rails application is accessed via an Alias directive, we MUST also set the RewriteBase in this htaccess file.

RewriteBase /redmine

Directory permissions:

The web server is ready but it can't do anything yet. First it needs a CGI script. In Redmine's public directory, rename the example script dispatch.cgi.example to dispatch.cgi.

Restart apache:

/var/www/redmine# /etc/init.d/apache restart

Now you should see Redmine's home page when you open http://192.168.10.11/redmine in your browser.

Redmine works now but it's very slow. This is where FastCGI comes in. The libapache2-mod-fcgid apache2 module or some more related packages have to be installed to make it faster.

# apt-get install libapache2-mod-fcgid

# apt-get install libfcgi-ruby1.8
# apt-get install libfcgi-dev
# gem install fcgi
# gem install mysql
  • rename the dispatch.fcgi.example file in the redmine public directory to dispatch.fcgi
  • make some configuration changes with regards to fastcgi/fcgid in the htaccess file
  • restart apache and enjoy the difference in speed :)

.htaccess file

AddHandler fastcgi-script .fcgi

AddHandler fcgid-script .fcgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteBase /redmine
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"

SMTP server Configuration

0.8.x releases:

Copy config/email.yml.example to config/email.yml and edit this file to adjust your SMTP settings.

See the Email configuration for redmine with no authentication

# Outgoing email settings

# config/email.yml

production:
delivery_method: :smtp
smtp_settings:
address: 192.168.10.11
port: 25
domain: debian.dass.com.np
authentication: :none

Useful Resources

0 comments:

Post a Comment

Followers