Binary Static

How to install Redmine from SVN with Apache Passenger and Postgresql

Posted in Applications, Linux, SysAdmin, Web by Chris on September 1, 2012

System: debian 6.0.5

Redmine’s standard debian packages are pretty outdated, so here’s how I installed its latest stable version. I used postgresql as database.

Get the latest stable version from the projects subversion. Do a checkout and keep the .svn directory for later updates on this branch:

# svn co http://redmine.rubyforge.org/svn/branches/2.0-stable /usr/share/redmine

Make sure ruby and rubygems and necessary libraries are installed:

# apt-get install ruby rubygems libpq-dev libmagickcore-dev libmagickwand-dev

Install bundler, which is ruby’s dependency manager, and rake, which is its build tool and conveniently to their executables:

# gem install bundler
# ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle
# gem install rake
# ln -s /var/lib/gems/1.8/bin/rake /usr/local/bin/rake

Change to the Redmine root directory and install all needed libraries with bundler:

# bundle install --without development test mysql sqlite

Configure /usr/share/redmine/config/database.yml:

production:
  adapter: postgresql
  database: redmine
  host: localhost
  username: redmine
  password: password
  encoding: utf8

Create the role and user in the postgresql database:

# su postgres
$ psql
postgres=# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD \
'password' NOINHERIT VALID UNTIL 'infinity';
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' \
OWNER=redmine;

Logout from the database and its user and generate the session token (again as root in /usr/share/redmine):

# rake generate_secret_token

Generate the database schema and load the fixtures:

# RAILS_ENV=production rake db:migrate
# RAILS_ENV=production rake redmine:load_default_data

Allow the Apache user (assuming www-data) access to relevant directories:

# mkdir tmp public/plugin_assets
# sudo chown -R redmine:redmine files log tmp public/plugin_assets
# sudo chmod -R 755 files log tmp public/plugin_assets

Test your installation by starting the built-in-server webrick, stop it with Ctrl-C:

# ruby script/rails server webrick -e production

Configure the named virtual host in
/etc/apache2/sites-available/tracking.codeways.org:

<VirtualHost *:80>
     ServerName tracking.codeways.org
     ServerAdmin admin@codeways.org

     DocumentRoot /usr/share/redmine/public

     RailsEnv production
     RailsBaseURI /
     <Location "/">
         Options ExecCGI FollowSymLinks
         Order allow,deny
         Allow from all
     </Location>
</VirtualHost>

At first, I linked to the Redmine root directory. This became unnecessary as I made it the document root of the vhost:

# ln -s /usr/share/redmine/public /srv/tracking.codeways.org

I configured e-mail (using exim4 and tls) in /usr/share/redmine/config/configuration.yml:

default:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      enable_starttls_auto: true
      address: mail.codeways.org
      port: 25
      domain: mail.codeways.org
      authentication: :plain
      user_name: "redmine"
      password: password

Start Redmine by restarting Apache:

# a2ensite tracking.codeways.org
# /etc/init.d/apache2 restart

Log into Redmine under http://tracking.codeways.org. Default username admin and password admin.

Tagged with:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: