Deploy Redmine 2.6 with Unicorn, Supervisor, and NginX

This blog post is about how to deploy Redmine 2.6, the opensourced project management software in a Ubuntu server with unicorn, supervisor and nginx.

A. Install Redmine:

1. Create a mariadb database for redmine:

* database name: redmine
* user: redmineuser
* password: redminepasswd

2. Clone the redmine's git repo:

$ git clone https://github.com/redmine/redmine.git
$ cd redmine
$ git checkout -b 2.6-stable

3. Configure database connection: Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment.

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmineuser
  password: redminepasswd

(for ruby 1.9)

4. Install dependencies:

$ gem install bundler
$ bundle install --without development test

5. Session store secret generation:

$ rake generate_secret_token

6. Database schema objects creation:

$ RAILS_ENV=production rake db:migrate

7. Database default data set:

$ RAILS_ENV=production rake redmine:load_default_data

8. File system permissions:

$ 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

(user here is redmine)

For more details, please read: http://www.redmine.org/projects/redmine/wiki/redmineinstall


B. Configure Unicorn and Supervisord:

0. Install Unicorn Herder: 

"Unicorn Herder is a utility designed to assist in the use of Upstart and similar supervisors with Unicorn. It does this by polling the pidfile written by the Unicorn master process, and automating the sequence of signals that must be sent to the master to do a "hot-reload". If Unicorn quits, so will the Unicorn Herder, meaning that if you supervise the herder (which does not daemonize), you are effectively supervising the Unicorn process."

$ sudo pip install unicornherder

For more information about Unicorn Herder, please read: https://github.com/gds-operations/unicornherder

1. Install unicorn: In redmine's root folder, create Gemfile.local with the following content:

gem 'unicorn'

Run this:

$ bundle install --without development test

2. Create an unicorn configuration, unicorn.rb, inside the config folder:



3. Create a supervisor configuration for redmine:



$ sudo supervisorctl reload
$ sudo supervisorctl start redmine

C. Configure nginx

Create a nginx configuration for redmine at /etc/nginx/sites-available/redmine:



$ sudo ln -s /etc/nginx/sites-available/redmine /etc/nginx/sites-enable/redmine
$ sudo service nginx restart


D. Appendix:

Using Flatly light redmine theme for Redmine

In the Redmine's root folder, go to public/themes/

$ git  clone https://github.com/Nitrino/flatly_light_redmine.git

Restart Redmine:

$ sudo supervisord restart redmine

In Redmine, go to Administration, Settings, Display and change display to user Flatly light redmine theme.


References:

[0] http://www.harryyeh.com/2012/10/redmine-setup-with-nginx-unicorn-rbenv.html
[1] https://github.com/Nitrino/flatly_light_redmine
[2] https://blog.nicolai86.eu/posts/2012-11-28/zero-downtime-deployments-with-unicorn-and-supervisord/

Comments