Philipp's Computing Blog

Success is about speed and efficiency

Redmine on Debian Squeeze

Redmine as Debian package:

  • The core package is redmine. Three packages (redmine-*) provide correct dependencies for mysql, pgsql, sqlite.
  • Several configurations are given as working examples in /usr/share/doc/redmine/examples.
  • Explanations of how the configuration is dealt with are given in /usr/share/doc/redmine/README.Debian.gz.
  • There is no per-instance support for plugins, but those dropped to /usr/share/redmine/vendor/plugins.

Manual and Up-To-Date Installation

Install requirements:

apt-get update
apt-get install git-core apache2 rubygems libopenssl-ruby libmysql-ruby libapache2-mod-fcgid libapache2-mod-passenger ruby mysql-server cron libnet-ssh-ruby1.8 python-setuptools
# If you like to use Gant-Charts (an additional ~40 MiB on my headless server):
apt-get install librmagick-ruby1.8
# Enable new apache modules:
a2enmod fcgid
a2enmod passenger
# Install the rails version needed (not the latest 2.3.x rails):
gem install -v=2.3.5 rails
# Link the rake version (that came with rails) to /usr/local/bin (may need to be adjusted to your version of rake):
ln -s /var/lib/gems/1.8/gems/rake-0.9.0/bin/rake /usr/local/bin/rake

Create the database:

DBPASSWORD=`pwgen -n1`
cat << EOF | mysql -uroot -p
CREATE USER '$DBUSER'@'localhost' identified by '$DBPASSWORD';
echo "The database user $DBUSER has been assigned the password $DBPASSWORD. Please remember the password."

Get redmine:

cd /var/lib
git clone
cd /var/lib/redmine
git checkout -b 1.1.3 1.1.3
# set the configuration
cat << EOF > config/database.yml
  adapter: mysql
  database: $DBNAME
  host: localhost
  username: $DBUSER
  password: $DBPASSWORD
  encoding: utf8
  schema_search_path: public" > config/database.yml

Initialize the installation:

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

Set up Apache for redmine:
cat << EOF > /etc/apache2/sites-available/$DOMAIN.redmine
<VirtualHost *>
  ServerAdmin $ADMINMAIL
  ServerName  $DOMAIN
  # If suexec-custom or suexec apache module is loaded, you can specify a special user:

  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/$DOMAIN.access.log combined
  ErrorLog /var/log/apache2/$DOMAIN.error.log

  ServerSignature Off
a2ensite $DOMAIN.redmine

# Passenger will be run as the owner of config/environment.rb:
chown $APACHEUSER: config/environment.rb
chmod 666 /var/lib/redmine/log/production.log
chown -R $APACHEUSER: files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

/etc/init.d/apache2 reload

You may now log in with username admin and password: admin.

Git integration:

apt-get install libnet-ssh-ruby1.8 python-setuptools gitosis git-daemon-run acl
gem install inifile lockfile net-ssh
# Loop file as repository storage
dd if=/dev/zero of=$LOOPFILE bs=1M count=1024
mkfs.ext3 `losetup -j $LOOPFILE | cut -d ':' -f 1` > ~root/repository-storage.about.mkfs.ext3 2>&1
mount -o acl `losetup -j $LOOPFILE | cut -d ':' -f 1` /mnt
mv /srv/* /mnt
umount /mnt
echo "$LOOPFILE    /scr   ext3   defaults,loop,acl    0    0" >> /etc/fstab
mount /srv

echo "ssh-keygen -t dsa" | su gitosis
echo "cat ~gitosis/.ssh/ | gitosis-init" | su gitosis
sed -i.orig 's:/var/cache:/srv/gitosis:g' /etc/sv/git-daemon/run
sv restart git-daemon
setfacl -m user:$APACHEUSER:r-x,mask:r-x ~gitosis/.ssh
setfacl -m user:$APACHEUSER:r--,mask:r-- ~gitosis/.ssh/id_dsa

cd /var/lib/redmine
# check <> for inspiration which to choose...
script/plugin install git://
echo "X_DEBIAN_SITEID=default RAILS_ENV=production rake db:migrate:plugins" | su $APACHEUSER
/etc/init.d/apache2 restart

Open your Browser, got to my_domain and login. Go to Administration → Plugins → Configure Redmine Gitosis plugin. Change localhost to Change to