HowTo Install Redmine on Debian Squeeze with Postgresql Ruby-on-Rails and Apache2-Passenger

This howto is similar to the HowTo Install Redmine on Debian with Ruby-on-Rails and Apache2-Passenger, but a little shorter and uses Postgresql instead of Mysql as the database server.
It should be noted that Redmine and all it's dependencies are available as packages in Debians' repo's, so there is no need to download Redmine from svn as we will do in this howto.

First we become root and install some needed packages:

apt-get install postgresql-8.4 apache2 subversion rake rubygems libopenssl-ruby libpgsql-ruby libapache2-mod-passenger
gem install -v=2.3.5 rails

Before configuring redmine we need to create a user and a database in Postresql. Make sure to replace <password> with your password.
su postgres
postgres=# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD '<password>' NOINHERIT VALID UNTIL 'infinity';
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine TEMPLATE template0;
postgres=# \q

Now, let's download Redmine and configure it
cd /tmp
svn co redmine-1.0
mv redmine-1.0/ /var/lib/redmine
cd /var/lib/redmine

First some database stuff. Replace <password> with your password.
echo "production:
 adapter: postgresql
 database: redmine
 host: localhost
 username: redmine
 password: <password>
 encoding: utf8
 schema_search_path: public" > config/database.yml

RAILS_ENV=production rake config/initializers/session_store.rb
rake generate_session_store
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data 

Finally, we setup Apache. A symbolic link to the www dir and ownership given to www-data.
ln -s /var/lib/redmine/public /var/www/redmine
chown -R www-data:www-data /var/www/redmine

We enable the site and restart Apache.
echo "RailsBaseURI /redmine" > /etc/apache2/sites-available/redmine
a2ensite redmine
/etc/init.d/apache2 restart

That's it. You will find Redmine at either:

your-ip/redmine or

If you need run redmine with a normal domain without alias (/redmine) you can follow the following instructions.

There are two possibilities:
  • use mod_fcgid
  • use the already installed mod_passenger

Use mod_fcgid
Install fcgid module for Apache

aptitude install libapache2-mod-fcgid

Configure a example VirtualHost /etc/apache2/sites-available/yourvirtualhost

<VirtualHost *:80>
  ServerAdmin mail@yourserver

  DefaultInitEnv RAILS_ENV production
  DefaultInitEnv GEM_PATH /var/lib/gems/1.8

  DocumentRoot /var/lib/redmine/public
  <Directory /var/lib/redmine/public>
    Options +FollowSymLinks +ExecCGI
    RewriteEngine On
    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly" 
    AllowOverride None
    #AllowOverride all
    Order allow,deny
    allow from all
  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog /var/log/apache2/access.log combined
  ErrorLog /var/log/apache2/error.log

  ServerSignature Off

Enable the new VirtualHost and restart Apache mod-rewrite also needs

cd /etc/apache2/sites-available
a2ensite yourvirtualhost
a2enmod rewrite
/etc/init.d/apache2 restart

Remember change owner and permissions of /var/lib/redmine/files/ (for upload files)

chown -R www-data:www-data /var/lib/redmine/files/
chmod -R 0777 /var/lib/redmine/files/

Log in with user: admin, password: admin

Use the already installed mod_passenger
(Tested with Debian 6.0.1, Apache 2.2.16 and mod_passenger 2.2.11)

Create a simple configuration file under /etc/apache2/sites-available:

<VirtualHost *:80>
  ServerAdmin mail@yourserver

  DocumentRoot /var/lib/redmine/public
  <Directory /var/lib/redmine/public>
    Options -MultiViews
    allow from all
  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog /var/log/apache2/access.log combined
  ErrorLog /var/log/apache2/error.log

  ServerSignature Off

Note: Remember to do the changes with owner and permissions.

Updated by C. X. almost 13 years ago · 11 revisions