Redmine is my favorite Project Managent Program.

Let’s see how to install redmine in Debian or Ubuntu.

00 - Add user redmine

If you are root:

adduser redmine

Add this user to sudoers.

adduser redmine sudo

So we’ll work with user redmine.

su - redmine

01 - Install RVM

\curl -L https://get.rvm.io | bash -s stable --rails

You can now take a coffee break.

We need to make our environment aware of the new RVM installation. You can see in your .bashrc file:

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

Active it with:

source ~/.bashrc

Some usefull orders:

rvm info
rvm list

Let’s try a Ruby page.

rails new sample
cd sample
rails s

And go to http://localhost:3000

rails_server

02 - Prepare database

Enter into MySQL command line:

mysql --user=root --password

And create database and user:

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

Exit and test:

mysql --host=127.0.0.1 --user=redmine --password=password_redmine redmine

03 - Download Redmine

wget http://www.redmine.org/releases/redmine-2.5.1.tar.gz
tar -xzvf redmine-2.5.1.tar.gz
cd redmine-2.5.1/
cp config/database.yml.example config/database.yml

Configure database:

production:
  adapter: mysql2
  database: redmine
  host: 127.0.0.1
  username: redmine
  password: password_redmine
  encoding: utf8
cp config/configuration.yml.example config/configuration.yml

Go to production section. In this case we’ll put sendmail option, you may read file for more options.

production:
  email_delivery:
    delivery_method: :sendmail

04 - Starting redmine

Install MySQL library dev and RMagick.

sudo apt-get install libmysqld-dev
sudo apt-get install libmagick++-dev

Install bundler and configure redmine:

gem install bundler
bundle install --without development test
rake generate_secret_token
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

Create folders:

mkdir -p tmp tmp/pdf public/plugin_assets
sudo chown -R redmine:redmine files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

And start redmine:

ruby script/rails server webrick -e production

Go to http://localhost:3000.

05 - Using puma

Add gem “puma” to Gemfile and execute bundle again:

bundle install --without development test

Add this config file to config/puma.rb

#!/usr/bin/env puma

application_path = '/home/redmine/redmine-2.5.1'
directory application_path
environment 'production'
daemonize true
pidfile "#{application_path}/tmp/pids/puma.pid"
state_path "#{application_path}/tmp/pids/puma.state"
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
bind "unix://#{application_path}/tmp/sockets/redmine.socket"

And try with:

bundle exec puma -C config/puma.rb

06 - Configure Nginx

upstream redmine {
  server unix:/home/redmine/redmine-2.5.1/tmp/sockets/redmine.socket;
}

server {
  listen 90;
  server_name localhost;
  root /home/redmine/redmine-2.5.1/public;

  access_log  /var/log/nginx/redmine_access.log;
  error_log   /var/log/nginx/redmine_error.log;

  location / {
    try_files $uri $uri/index.html $uri.html @redmine;
  }

  location @redmine {
    proxy_read_timeout 300;
    proxy_connect_timeout 300;
    proxy_redirect     off;

    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              $http_host;
    proxy_set_header   X-Real-IP         $remote_addr;

    proxy_pass http://redmine;
  }
}

Restart Nginx:

nginx -s stop
nginx

07- Monit start

Install monit:

sudo apt-get install monit

General configuration file /etc/monit/monitrc add:

set httpd port 2812
  allow admin:pass

Into /etc/monit/conf.d/ add file redmine:

check process redmine with pidfile /home/redmine/redmine-2.5.1/tmp/pids/puma.pid 
start program = "/bin/su redmine -lc 'cd /home/redmine/redmine-2.5.1  && /home/redmine/.rvm/gems/ruby-2.1.2/bin/puma -C /home/redmine/redmine-2.5.1/config/puma.rb'"
stop program = "/bin/su redmine -lc 'kill -TERM $(cat /home/redmine/redmine-2.5.1/tmp/pids/puma.pid)'"

And restart monit:

service monit restart

Go to monit web:

http://localhost:2812/redmine

monit_server

08 - Enter in redmine

Go to redmine:

http://localhost:2812/redmine

user: admin pass: admin

And now you can start your projects!