HowTo Install Redmine 210 on Debian Squeeze with Apache Passenger

This manual was originally posted here: http://beeznest.wordpress.com/2012/09/20/installing-redmine-2-1-on-debian-squeeze-with-apache-modpassenger/

This article is co-authored by Jérôme Warnier, from work mostly done by him with my occasional support. Kudos go to him.

We couldn't find any valuable manual to install Redmine 2.1 on Debian Squeeze, and we sure met a lot of resistance along the way, so we came up with the following step-by-step guide...

Assumptions

We take as given that:

  • We are using a Debian Squeeze installation
  • We have root access to this machine
  • There is public access to the machine itself (public IP)
  • We are able to define a public domain (or subdomain) name for this Redmine installation
  • We have access to define a database (we chose MySQL) user for Redmine (this is important to avoid security risks in sharing accounts with another web system). We also assume that we already have a MySQL server installation
  • We will be using Apache 2's modPassenger (and Apache 2 is already installed on the server)
  • We will be using redmine.example.com; so every time you see this below, replace it by your own domain

Warming up

We will first need to install basic packages:

apt-get install ruby ruby-dev rubygems libruby libapache2-mod-passenger

Download the latest version of Redmine (2.1.0 in our case) and untar it, then move it to /usr/local/share
wget http://rubyforge.org/frs/download.php/76448/redmine-2.1.0.tar.gz
tar -xvf redmine-2.1.0.tar.gz
mv redmine-2.1.0 /usr/local/share/redmine-2.1.0
ln -s /usr/local/share/redmine-2.1.0 /usr/local/share/redmine
chown -R root:root /usr/local/share/redmine-2.1.0

Install development libraries for MySQL:

apt-get install libmysqlclient-dev

Install development libs for Imagick:

apt-get install libmagickcore-dev libmagickwand-dev (install shitload of packages)

Running the Gem stuff

Install Bundler (removing useless module, which would otherwise create dependencies):

gem install bundler
cd /usr/local/share/redmine/
bundle install --without development test postgresql sqlite
#maybe you have to use
/var/lib/gems/1.8/bin/bundle install --without development test postgresql sqlite

Configuration

Open a mysql session

 CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';

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

mv config/database.yml.example config/database.yml

Example for a MySQL database using ruby1.8 or jruby:
production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: my_password

Generate a session store secret:

rake generate_secret_token

Generate the database structure:

RAILS_ENV=production rake db:migrate

Generate default configuration data:

RAILS_ENV=production rake redmine:load_default_data

(using “es” for Spanish language in terminal prompt)

Setup config file in config/configuration.yml

Change database_ciphr_key: *

rake db:encrypt RAILS_ENV=production

Apache

Setup Apache’s VirtualHost config

vim /etc/apache/site-available/redmine.example.com

and insert the following text:
# 8080 in this case is because we use a reverse proxy before Apache. Otherwise simply use "*:80" 

<VirtualHost *:8080>
 ServerName redmine.example.com
 DocumentRoot /usr/local/share/redmine/public
 <Directory /usr/local/share/redmine/public>
   AllowOverride all
   Options -MultiViews
 </Directory>
</VirtualHost>

Once you enable this virtual host (a2ensite redmine.example.com) and reload Apache (/etc/init.d/apache2/reload), you should see your site running on http://redmine.example.com.

If you can't create or edit Users, delete the chache folder in /opt/redmine

The default login/password is admin/admin (don't forget to change this).

Sources of inspiration

We used the following resources as a starting point. Thanks to their respective authors.