Monday, December 30, 2013

Simple Redmine deployment

Redmine is simpler to deploy than it might first appear. First, ignore you OSes rails etc. packages, other than the most basic:
yum install ruby
yum install ruby-devel
yum install rubygems
yum install gcc
yum install ImageMagick-devel
yum install sqlite-devel
Grab the most recent version of Redmine and install:
wget http://rubyforge.org/frs/download.php/77242/redmine-2.4.0.tar.gz
mv redmine-2.4.0.tar.gz /usr/local/src
cd /usr/local/src
gunzip redmine-2.4.0.tar.gz 
tar xvf redmine-2.4.0.tar 
cd redmine-2.4.0
cp config/database.yml.example config/database.yml
I just commented out the mysql connector in database.yml and uncommented production/sqlite3 as it's plenty fast enough for the simple projects I need to manage. Let bundler take care of installing the correct gems:
gem install bundler
bundle install
Create a secret token in configuration.yml, and migrate the db:
rake db:migrate RAILS_ENV="production"
cp config/configuration.yml.example config/configuration.yml
I wanted to use WEBrick and ssl, so retrieved this gist: https://gist.github.com/simi/1292552 and changed the port to 443. Generate a self-signed cert from the instructions at: http://www.sslshopper.com/article-how-to-create-and-install-an-apache-self-signed-certificate.html and put the generated file in their appropriate places, namely vendor/ssl/redmine.crt and vendor/ssl/redmine.key. For completeness, I created a /etc/init.d/webrick CentOS file:
#!/bin/bash
#
# chkconfig: 3 90 90
# description: run redmine WEBrick

### BEGIN INIT INFO
# Provides: webrick
# Required-Start: $network $local_fs
# Should-Start:
# Short-Description: run redmine WEBrick
# Description: run redmine WEBrick
### END INIT INFO

start() {
    /usr/local/src/redmine-2.4.0/script/rails server -e production -d
}

stop() {
    kill -KILL `cat /usr/local/src/redmine-2.4.0/tmp/pids/server.pid`
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status
    ;;
  restart|force-reload)
    stop
    start
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|force-reload}"
    exit 2
esac
"sudo chkconfig --add webrick" and "sudo server webrick start" kick things off in the right direction. Yeah, this is a little long, but I think a bit easier than other approaches.

No comments: