Redmine + Mongrel + Cherokee / Apache

 

Cet article présente une installation de Redmine en passant par un proxy Apache ou Cherokee.

Installation de Redmine

Dépendances

Paquets nécessaires pour Ruby :

# apt-get install ruby1.8 ruby1.8-dev rake rubygems1.8 libopenssl-ruby1.8 librmagick-ruby1.8

 

Paquets nécessaires pour Mysql :

# apt-get install libmysqlclient16 mysql-server mysql-client libmysqlclient-dev

 

Gems Ruby :

# gem install rails -v=2.3.11
# gem install -v=0.4.2 i18n
# gem install mysql

# gem list

*** LOCAL GEMS ***

actionmailer (2.3.11)
actionpack (2.3.11)
activerecord (2.3.11)
activeresource (2.3.11)
activesupport (2.3.11)
i18n (0.4.2)
mysql (2.8.1)
rack (1.1.2)
rails (2.3.11)
rake (0.9.2)

 

Mise en place du code

# mkdir -p /var/www/redmine.cheramy.name/{var/{log,tmp/upload},etc,tmp}
# cd /var/www/redmine.cheramy.name/
# git clone https://github.com/edavis10/redmine.git

Création d'une base de données vide

mysql> create database redmine character set utf8 ;
mysql> grant all privileges on redmine.* to 'red_uzer'@'localhost' identified by 'ahMu8eihaer7' with grant option ;

Configuration

# cd redmine/config
# cp database.yml.example database.yml

Editer database.yml :

production:
  adapter: mysql
  database: redmine
  host: localhost
  username: red_uzer
  password: ahMu8eihaer7
  encoding: utf8

 

Initialisation

# rake generate_session_store

 

J'ai eu l'erreur suivante :

(in /var/www/redmine.cheramy.name/redmine)
rake aborted!
uninitialized constant Rake::DSL
/var/www/redmine.cheramy.name/redmine/Rakefile:7
(See full trace by running task with --trace)

 

Il faut rajouter dans le fichier Rakefile :
require 'rake/dsl_definition'
avant
require 'rake'

Puis :

# rake generate_session_store
# RAILS_ENV=production rake db:migrate --trace

On charge la configuration par défaut

# RAILS_ENV=production rake redmine:load_default_data
(in /var/www/redmine.cheramy.name/redmine)
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/file_utils.rb:10: warning: already initialized constant RUBY
/var/lib/gems/1.8/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)

Select language: bg, bs, ca, cs, da, de, el, en, en-GB, es, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] fr
====================================
Default configuration data loaded.

Les répertoires suivants doivent être accessible en écriture pour l'utilisateur exécutant redmine (www-data) :

chown -R www-data.www-data files log public/plugin_assets tmp

 

Pour tester

# ruby script/server webrick -e production &
[2] 20303
root@zombillenium:/var/www/redmine.cheramy.name/redmine# => Booting WEBrick
=> Rails 2.3.11 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-08-05 16:19:19] INFO  WEBrick 1.3.1
[2011-08-05 16:19:19] INFO  ruby 1.8.7 (2010-08-16) [x86_64-linux]
[2011-08-05 16:19:19] INFO  WEBrick::HTTPServer#start: pid=20303 port=3000

 

Installation de Mongrel


Comme précisé dans la doc, il ne faut pas utiliser Webrick en prod:
Webrick is not suitable for normal use, please only use webrick for testing that the installation up to this point is functional. It is not recommended to use webrick for anything other than development. Use one of the many other guides in this wiki to setup redmine to use either passenger (aka mod_rails) or mongrel to serve up your redmine.

On va donc utiliser Mongrel :

# apt-get install  mongrel mongrel-cluster

 

On crée le fichier de configuration :

# mongrel_rails cluster::configure -e production -p 8080 -N 3 -c /var/www/redmine.cheramy.name/redmine/ -C /var/www/redmine.cheramy.name/redmine/config/mongrel_cluster.yml -a 127.0.0.1 --user www-data --group www-data
Writing configuration file to /var/www/redmine.cheramy.name/redmine/config/mongrel_cluster.yml.

# -e production indique que le serveur doit tourner en mode production
# -p 8080 lance Mongrel sur le port 8080
# -N 3 indique qu'il y aura 3 instances du serveur
# -c /var... le chemin vers la racine de Redmine
# -C /var... le chemin vers où le fichier de configuration va être créé
# -a dit à Mongrel d'écouter seulement sur l'interface localhost

 

On crée le lien pour le serveur mongrel :

# ln -s /var/www/redmine.cheramy.name/redmine/config/mongrel_cluster.yml /etc/mongrel-cluster/sites-enabled/redmine.yml

 

On démarre :

# /etc/init.d/mongrel-cluster restart

 

On vérifie que ça à bien démarré :

# netstat -tpnl | grep ruby
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN      28629/ruby1.8 
tcp        0      0 127.0.0.1:8081          0.0.0.0:*               LISTEN      28632/ruby1.8 
tcp        0      0 127.0.0.1:8082          0.0.0.0:*               LISTEN      28635/ruby1.8 

 

Malheuresement il y a un petit problème avec mongrel et la version de rails :

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586118

 

Récupérer le patch :

# cd /usr/lib/ruby/1.8/mongrel/
# wget https://rails.lighthouseapp.com/projects/8994/tickets/4690/a/554107/rails238_mongrel115_patch.diff
# patch -p1 < rails238_mongrel115_patch.diff

Cherokee / Apache

 

Il suffit maintenant de configurer votre serveur Web Cherokee ou Apache en tant que reverse proxy http.