Wednesday, November 11, 2015

Installing Redmine on Linux Debian (Jessie) with Nginx + Thin

Installing Redmine on Linux Debian (Jessie) with Nginx + Thin


If you tried to install Redmine with Nginx you know that it's very interesting task.

Let's solve this task.

This document based on "Installing Redmine with MySQL Thin and Redmine on Debian Squeeze" and fixes few issues with base document

Also, you can find some useful tricks here:



Redmine main page says that Redmine is: 
a flexible project management web application. Written using the Ruby on Rails framework, it is cross-platform and cross-database.

Redmine is open source and released under the terms of the GNU General Public License v2 (GPL).

We will do all operations from regular user uses sudo commands.


Installing MySQL

$ sudo apt-get install mysql-server

Till installation process you will be asked for main administrator's password.

Adding Redmine database

$ mysql -u root -p
mysql> CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'newpassword';
mysql> CREATE DATABASE redmine_default CHARACTER SET = 'utf8';
mysql> GRANT ALL PRIVILEGES ON redmine_default.* TO 'redmine'@'localhost';
Warn! newpassword is new password of redmine user. Please, change it for actual password.

Installing Nginx, Redmine and Thin.

$ sudo apt-get install redmine redmine-mysql thin nginx

When prompted during the installation, choose yes to use dbconfig-common, choose mysql as the database, and supply the root and redmine MySQL user's passwords when prompted. dbconfig-common will notice that the database already exists and populate it without changing the character set, which will result in all tables having the UTF-8 character set.

Configuring thin

Adding a directory in which to store the log files created by Thin:

$ sudo mkdir /var/log/thin
$ sudo chmod 755 /var/log/thin

Base document notes that:

If access to the Thin logs need to be further restricted on the server, this directory may be owned by root:adm and set to mode 2750 to restrict access to users in the adm group.

Generating Thin config:

$ thin config --config /tmp/redmine.yml --chdir /usr/share/redmine \
    --environment production --socket /var/run/redmine/sockets/thin.sock \
    --daemonize --log /var/log/thin/redmine.log --pid /var/run/thin/ \
    --user www-data --group www-data --servers 1 --prefix /redmine 
$ sudo ln -s /etc/thin2.1/ /etc/thin 
$ sudo mv /tmp/redmine.yml /etc/thin/redmine.yml
$ sudo chown root:root /etc/thin/redmine.yml
$ sudo chmod 644 /etc/thin/redmine.yml
$ sudo chown root:root /etc/thin/redmine.yml
$ sudo chmod 644 /etc/thin/redmine.yml

Base document say's:

Note that --servers can be adjusted based on the expected load and other performance considerations. Also, the --prefix option can be adjusted or omitted to change the URL prefix used to access Redmine. Using /redmine will provide access to Redmine at http://host/redmine, omitting the prefix would provide access at the site root http://host/

You can see string which marked bold. This string creates /etc/thin directory which does not exists on my Debian installation. As you can see, I making link from thin2.1 but your installation of Thin can have other version. Please, check it manually.

Adding logging support for Thin via logrotate configuration:

$ sudo nano /etc/logrotate.d/thin

With this content:

/var/log/thin/*.log {
        rotate 52
        create 640 root adm
                /etc/init.d/thin restart >/dev/null

Configuring Nginx

Configuring proxy_params settings via editing file /etc/nginx/proxy_params We need configuration like this:

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

Adding configuration for our site. Adding configuration file named /etc/nginx/sites-available/redmine

$ sudo nano /etc/nginx/sites-available/redmine

With this content:

upstream redmine_thin_servers {
        server unix:/var/run/redmine/sockets/thin.0.sock;
        # Add additional copies if using multiple Thin servers
        #server unix:/var/run/redmine/sockets/thin.1.sock;

server {

        listen   80; ## listen for ipv4
        listen   [::]:80 default ipv6only=on; ## listen for ipv6

        # Set appropriately for virtual hosting and to use server_name_in_redirect
        server_name  your_site_name;
        server_name_in_redirect off;

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

        # Note: Documentation says proxy_set_header should work in location
        #       block, but testing did not support this statement so it has
        #       been placed here in server block
        include /etc/nginx/proxy_params;
        proxy_redirect off;

        # Note:  Must match the prefix used in Thin configuration for Redmine
        #        or / if no prefix configured
        location /redmine {
                root   /usr/share/redmine/public;

                error_page 404  404.html;
                error_page 500 502 503 504  500.html;

                try_files $uri/index.html $uri.html $uri @redmine_thin_servers;

        location @redmine_thin_servers {
                proxy_pass http://redmine_thin_servers;

Please, note that your_site_name must be actual name of your site. For debugging you can set it as localhost. If you want few DNS names must be processed with same app, you can set few names separated by space, like:

your_site_name1 your_site_name2 your_site_name3;

Optionaly you can remove default site:

$ sudo rm /etc/nginx/sites-enabled/default

Adding link to our site:

$ sudo ln -s /etc/nginx/sites-available/redmine /etc/nginx/sites-enabled/redmine

Fixing security issues

Fixing security issues (which not allows to run Thin and Redmine):

$ sudo chown -R www-data:www-data /var/run/thin/

$ sudo mkdir /var/run/redmine

$ sudo mkdir /var/run/redmine/sockets/

$ sudo chown -R www-data:www-data /var/run/redmine

Fixing Redmine static files issue

Now we need fix issue with Redmine static files (.css, .js and so on). We need open file usr/share/redmine/config/environment.rb

$ sudo nano /usr/share/redmine/config/environment.rb

And add line at the end:

Redmine::Utils::relative_url_root = "/redmine"

Which will tell Redmine about our prefix-route.

Restarting and testing

Restarting services:

$ sudo service thin restart
$ sudo service nginx restart

Now you can go to address:


For example (if you installed for localhost) to:


You can log in using login admin and password admin. This is default login and password for Redmine.


If the Redmine page does not appear, here are some troubleshooting suggestions:
  1. Check the nginx error log /var/log/nginx/error.log for relevant errors.
  2. Check the Thin log for errors, /var/log/thin/redmine.0.log.
  3. Add debug to the Redmine Thin configuration, restart, retry, and re-check the Thin log.
  4. Change the Redmine Thin configuration to use an address and port instead of a socket and connect directly to Thin from a web browser to determine if the problem is with Thin or nginx.

Hope your installation work's.

Feel free to ask questions via comments.



  1. Hello. Thank you for this guide. It is very complete and usefull.
    I have a question. I migrated from a debian package to the 2.6.0 redmine version (zip file). Al worked with same configuration (except thin config that I rebuilt).

    Then I upgraded to 3.2.0 redmine version using official guide. I continue to use Thin and nginx.

    Now Redmine is always in error 500 and in my Thin logs, I have on each request:
    !! Unexpected error while processing request: uninitialized constant Rack::URLMap::PATH_INFO

    I suppose it is a misconfiguration of nginx but I can't find the problem. I found people having the same problems but without solution.

    Did you encounter this error ? Do you have an idea to resolve this ?


    1. Sorry man, no any ideas. Need to check logs again and again and google for answer. Sure you find it! Good luck!

  2. alhamdulillah, its work. thanks a lot.

    1. You're welcome! Glad that information was useful to you!

  3. Sorry for the question, but since upstream redmine_thin_servers is "/var/run/redmine/sockets/thin.0.sock", wouldn't this cause a missmatch with thin config --socket /var/run/redmine/sockets/thin.sock ? Aren't they supposed to be the same? Thank you!

    1. Can you check both solutions and give information about valid one? Thank you