There is a new version of this tutorial available for Debian 11 (Bullseye).

Running Redmine Project Management On nginx (Debian Wheezy)

Redmine is a project management tool written in Ruby. This tutorial explains how to serve Redmine with the help of thin (a fast Ruby webserver) through an nginx webserver on Debian Wheezy.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

I have prepared a website with the document root /var/www/ (Redmine will be installed there) that is owned by the user web1 and the group client0.

I have also prepared a MySQL database for Redmine with the name c0db1. The username is c0db1 as well, the password is FyZ5z4QGfhTf8.


2 Installing Redmine

First we install some prerequisites:

apt-get install thin ruby rake rubygems libopenssl-ruby libmysql-ruby librmagick-ruby ruby-dev libmysqlclient-dev libmagick-dev curl
gem install sass
gem install compass

Download the latest Redmine and copy it to our document root /var/www/

cd /tmp
tar xvfz redmine-2.4.2.tar.gz
mv redmine-2.4.2/* /var/www/
cd /var/www/
chown -R web1:client0 *

Fill in the login details for our MySQL database:

cp config/database.yml.example config/database.yml
vi config/database.yml
  adapter: mysql2
  database: c0db1
  host: localhost
  username: c0db1
  password: "FyZ5z4QGfhTf8"
  encoding: utf8

Install some other needed packages and fill the database:

apt-get install libmagickwand-dev
gem install rmagick
gem install bundler
bundle install --without development test postgresql sqlite
rake generate_secret_token
rake db:migrate RAILS_ENV="production"
rake redmine:load_default_data RAILS_ENV="production"


3 Configuring thin

Next we configure thin, our Ruby webserver that nginx will proxy requests to.

ln -s /etc/thin1.9.1 /etc/thin
mkdir /var/log/thin
chmod 755 /var/log/thin
cd /etc/thin

Create a thin configuration file that is named like the owner of the document root (web1):

vi web1.yml

Make sure to use the correct user (web1) in the log, pid, socket and user lines as well as the correct group (client0) in the group line. Use the correct document root in the chdir line:

chdir: /var/www/
environment: production
timeout: 30
log: /var/log/thin/web1.log
pid: /var/run/thin/
max_conns: 1024
max_persistent_conns: 512
require: []
wait: 30
socket: /var/run/thin/web1.sock
daemonize: true
user: web1
group: client0
servers: 1
prefix: /

Create the /var/run/thin directory (where thin will create its socket):

mkdir /var/run/thin
chown -R web1:client0 /var/run/thin

In order to make sure the directory exists when thin is started, we add the line test -e /var/run/thin || install -m 755 -o web1 -g client0 -d /var/run/thin to the /etc/init.d/thin init script (right after the SCRIPT_NAME line):

vi /etc/init.d/thin

test -e /var/run/thin || install -m 755 -o web1 -g client0 -d /var/run/thin


Now start thin...

/etc/init.d/thin start

... and take note of the socket it creates (/var/run/thin/web1.0.sock in this case) - we'll need it in the nginx configuration:

root@server1:/etc/thin# /etc/init.d/thin start
[start] /etc/thin1.9.1/web1.yml ...
Starting server on /var/run/thin/web1.0.sock ...

If you're using Monit, you can add the following lines to /etc/monit/monitrc to make sure thin is always running:

vi /etc/monit/monitrc
check process thin with pidfile /var/run/thin/
   start program = "/etc/init.d/thin start"
   stop  program = "/etc/init.d/thin stop"

Restart Monit afterwards:

/etc/init.d/monit restart


4 Configuring nginx

Next we must configure our nginx vhost through which we want to access Redmine. You must paste the following configuration into your server {} container (or the nginx Directives field if you use ISPConfig) - make sure you use the correct thin socket:

client_max_body_size 100M;

location / {
    proxy_set_header X-Reak-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    if (-f $request_filename/index.html) {
      rewrite (.*) $1/index.html break;

    if (-f $request_filename.html) {
      rewrite (.*) $1.html break;

    if (!-f $request_filename) {
      proxy_pass http://unix:/var/run/thin/web1.0.sock;

That's it! Now visit your website, and you should be able to use Redmine. The default username is admin, the password is admin as well.


Share this page:

5 Comment(s)