redmine lighttpd

This short guide documents the steps I had to take to install Redmine on Ubuntu 8.10 Server running Lighttpd and MySQL. Each of the guides I used as references had its own deficiencies when applied to my setup, so I compiled my own.

Install Redmine and its dependencies

First of all, install all Redmine dependencies:

# apt-get install ruby rake librmagick-ruby libmysql-ruby rubygems libfcgi-ruby1.8 libopenssl-ruby1.8

We're going to install current release version of Redmine, 0.8.5, so we need to figure out the correct version of Rails using the table below:

Redmine version Supported Ruby versions Required Rails version
current trunk ruby 1.8.6, 1.8.7 Rails 2.3.4
trunk from r2493 to r2886 ruby 1.8.6, 1.8.7 Rails 2.2.2
trunk before r2493 ruby 1.8.6, 1.8.7 Rails 2.1.2
0.8.x ruby 1.8.6, 1.8.7 Rails 2.1.2
0.7.x ruby 1.8.6 Rails 2.0.2

Then install the appropriate version of Rails using Ruby's package manager, RubyGems:

gem install rails -v=2.1.2

Starting from 0.9.x, Redmine also requires rack:

gem install rack -v=1.0.1

We're going to install Redmine under /var/www/. Download and unpack the Redmine tarball:

$ cd /var/www/
$ wget http://rubyforge.org/frs/download.php/63583/redmine-0.8.5.tar.gz
$ tar xzvf redmine-0.8.5.tar.gz
$ mv redmine-0.8.5 redmine

Database setup

Next step is to create a MySQL database for Redmine and specify database connection details in Redmine's database config file. Fire up your MySQL client and type:

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

Edit /var/www/redmine/config/database.yml, production section, and specify the user, password and database created above:

production:
  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: my_password

Run rake under Redmine's root directory to create the neccessary database structures and populate them with default configuration data:

$ cd /var/www/redmine
$ rake db:migrate RAILS_ENV="production"
$ rake redmine:load_default_data RAILS_ENV="production"

Lighttpd setup

Create Redmine FastCGI dispatch file:

$ cp public/dispatch.fcgi.example public/dispatch.fcgi

After creating the dispatch file, add a virtual host for Redmine to /etc/lighttpd/lighttpd.conf and configure FastCGI:

$HTTP["host"] =~ "^example\.org$" {
    server.document-root = "/var/www/redmine"
    server.errorlog = "/var/log/redmine_error.log"
    accesslog.filename = "/var/log/redmine_access.log"
    server.indexfiles = ("dispatch.fcgi")
    server.error-handler-404 = "/dispatch.fcgi"

    url.rewrite-once = (
        "^/(.*\..+(?!html))$" => "$0",
        "^/(.*)\.(.*)"        => "$0",
    )

    fastcgi.server = (
        ".fcgi" => (
            "redmine" => (
                "bin-path" => "/usr/bin/ruby /var/www/redmine/public/dispatch.fcgi",
                "socket" => "/tmp/redmine.socket",
                "min-procs" => 1,
                "max-procs" => 4,
                "idle-timeout" => 120,
                "check-local" => "disable",
                "bin-environment" => ("RAILS_ENV" => "production"),
            )
        )
    )
}

Test that the configuration file's syntax is OK:

# lighttpd -t -f /etc/lighttpd/lighttpd.conf

If everything's fine, restart Lighttpd to reload the config file:

# /etc/init.d/lighttpd restart

And we're done!

Email notifications

For Redmine to be able to send out email notifications to its users it has to be configured for your email setup. First, create an email config file from the example config that comes with Redmine:

$ cp config/email.yml.example config/email.yml

Your configuration will depend on what kind of email setup you use. If there is an MTA running on the same machine, the setup is straightforward:

production:
   delivery_method: :smtp
   smtp_settings:
     authentication: :none
     domain: example.org
     address: 127.0.0.1
     port: 25

Another option is to use a sendmail-compatible mail delivery agent, such as msmtp:

production:
    delivery_method: :sendmail
    sendmail_settings:
        location: /usr/bin/msmtp
        arguments: -t -i
        domain: example.org

Troubleshooting

If you get the following error when you try to create the table structures for Redmine, you have to install libopenssl-ruby1.8:

$ rake db:migrate RAILS_ENV="production"
(in /var/www/redmine)
rake aborted!
no such file to load -- openssl

(See full trace by running task with --trace)

However, if you followed the instructions above closely, you should have already installed this missing dependency.

References

  1. Official Redmine installation guide
  2. Install the Redmine project management application on Debian 4.0 Etch
  3. Redmine + SVN + MySQL 5 + Lighttpd 1.5 + FastCGI
  4. Redmine on Debian Lenny Using Lighttpd