Installing Redmine + rbenv on Debian 6/7 including Basic-Auth-Login w/ Apache || Nginx

This document describes a custom Redmine-Installation on Debian 6/Squeeze and Debian 7/Wheezy for MySQL or Postgres, with HTACCESS-Auth-Plugin and Email-Configuration.

This is merely a collection of shortcuts and the right path for an installation as a reminder for admins, not a full-scale howto; if you need more infos, plese refer to the links, provided in this document

Docs

installing dependencies, as root

aptitude install  build-essential bison openssl curl git-core zlib1g zlib1g-dev screen libruby libcurl4-openssl-dev libssl-dev libmysqlclient-dev libxml2-dev  libmagickwand-dev libpq-dev imagemagick
aptitude install rbenv ruby-build  ruby-dev 

# pg
aptitude install postgresql-9.1  postgresql-server-dev-9.1


# mysql 

umask 022
gem install bundler
gem install json -v '1.8.1'
# mysql
CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'ALLUNDERTHESUN;
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
FLUSH PRIVILEGES;

# postgres
CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'ALLUNDERTHESUN' NOINHERIT VALID UNTIL 'infinity';
CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;

preparing rbenv and installing needed ruby - version

# ~/.profile || ~/.bashrc || ~/.bash_profile
# ...

# rbenv - setting
PATH="$HOME/.rbenv/bin:$PATH"
export PATH
# to detect .rbenv-version
eval "$(rbenv init -)"

# prod
RAILS_ENV="production"
export RAILS_ENV
# listing installable ruby-versions 
rbenv rehash
rbenv install 

# install me a custom ruby
rbenv install 1.9.3-p194

Sidenote debian 6

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

$ gem install bundler
$ gem install json -v '1.8.1'

installing Redmine

# checkout (latest version)
git clone https://github.com/redmine/redmine 


# wgetting sources (stable version, check website for updates)
wget -O redmine.tgz http://www.redmine.org/releases/redmine-2.5.1.tar.gz
tar xzf redmine.tgz
cd redmine/

# configuring redmine
cp config/database.yml.example config/database.yml
vi config/database.yml # adjust your setup
RAILS_ENV="production"
export RAILS_ENV

# creating your local .rbenv-version; 
#  rbenv help local -> display help and installed/available versions
rbenv local 1.9.3-p194

gem install bundler
gem install json -v '1.8.1'

bundle install --without development test
bundle exec rake db:migrate
bundle exec rake generate_secret_token
REDMINE_LANG=en bundle exec rake redmine:load_default_data 
bundle exec ruby script/rails server webrick -e production -b 127.0.0.1 -p 3000
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/bin/bash
# start_redmine.sh, place this inside your redmine-folder
RAILS_ENV="production"
export RAILS_ENV
pid="tmp/pids/server.pid"
# ok, this is hard now
if [ -f $pid ]; then
  echo "> killing old instance"
  kill -TERM `cat $pid`
  rm $pid
fi

bundle exec ruby script/rails server webrick -e production -b 127.0.0.1 -p 3000 -d > redmine.log

Redmine + Mails

the redmine-way:

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


production:
  email_delivery:
    delivery_method: :async_smtp
    async_smtp_settings:
      address: smtp.example.com
      port: 25
      domain: example.net
      authentication: :login
      user_name: redmine@example.com
      password: redmine
# /etc/postfix/main.cf
relayhost = smtp.example.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smarthost
smtp_sasl_security_options = noanonymous

# /etc/postfix/smarthost
smtp.example.com:587 userid:password

# dont forget to 
# postmap  /etc/postfix/smarthost && /etc/init.d/postfix restart

Redmine + BasicAuth + Apache / Nginx - Examples

cd redmine
cd plugins &&  git clone https://github.com/pburgisser/redmine_http_basic_authentication.git
cd ..
RAILS_ENV="production" bundle exec rake redmine:plugins:migrate
<VirtualHost *:80>

    ServerName redmine.example.com


   ProxyRequests Off
   ProxyPreserveHost On
   ProxyPass / http://localhost:3000/
   ProxyPassReverse / http://localhost:3000/

   CustomLog /var/log/apache2/redmine.access.log combined
   ErrorLog /var/log/apache2/redmine.error.log

  <Location / >

        AuthType Basic
        AuthName "Restricted"
        AuthUserFile /etc/htpasswd/redmine.htaccess
        Require valid-user

  </Location>




</VirtualHost>
server {
  listen 80;
  server_name redmine.example.com;
  server_tokens prod;
  proxy_cache off;

  auth_basic "Restricted";
  auth_basic_user_file   /etc/htpasswd/redmine.htaccess;

  access_log  /var/log/nginx/redmine.access.log;
  error_log   /var/log/nginx/redmine.error.log;

  location / {

    proxy_pass http://localhost:3000/;

  }

Refs

date: 2014.04
tags: apache debian devops nginx rails redmine

You code … we platform.