Redmine – Upgrade to 1.4.4 on a debian squeeze

This document describes how to upgrade Redmine. The procedure was tested for upgrade from version 1.0.1 to 1.4.4, but it might works on other Redmine versions.
In this procedure I used a basic install of a debian squeeze (the only service installed was openssh-server). I am assuming the server has network connectivity and its IP is 10.34.133.220.

Please note:
- please announce all people BEFORE starting this procedure
- the Apache server on production environment MUST be stopped so after the upgrade the database be in sync.
- this version of Redmine needs ruby version 1.8.7 or 1.9.3 (I am going to use the debian squeeze default ruby package which has version 1.8.7)
- all rsync-ed files in this procedure are attached

1. Login to the remote machine

ssh root@10.34.133.220

2. Configure hostname

echo "workflow-vm" > /etc/hostname

3. Install all required packages for Redmine installation

aptitude install apache2 mysql-server ruby libmysqlclient-dev libmagickcore-dev libmagickwand-dev imagemagick locate less rubygems sudo postfix mercurial cvs subversion darcs git libapache2-mod-passenger libxslt1-dev vim less

4. Configure and test postfix

scp root@workflow-sandbox-vm.test.org:/etc/mailname /etc/
scp root@workflow-sandbox-vm.test.org:/etc/postfix/main.cf /etc/postfix/
 
echo "root: user@test.org" >> /etc/aliases
 
vim /etc/mailname
:%s/workflow-sandbox-vm.test.org/workflow-vm.test.org
:wq
 
vim /etc/postfix/main.cf
:%s/workflow-sandbox-vm.test.org/workflow-vm.test.org
:wq
 
newaliases
/etc/init.d/postfix restart
 
echo "test from new redmine server" | mail -s "test from new redmine server" "user@test.org"

5. Configuring mysql database

mysql -Bsu root -pmysql123 -e "drop database redmine;"
mysql -Bsu root -pmysql123 -e "drop user redmine@localhost;"
mysql -Bsu root -pmysql123 -e "create database redmine character set utf8;"
mysql -Bsu root -pmysql123 -e "create user 'redmine'@'localhost' identified by 'redmine';"
mysql -Bsu root -pmysql123 -e "grant all privileges on redmine.* to 'redmine'@'localhost';"
mysql -Bsu root -pmysql123 -e "flush privileges;"
# dump mysql database from production environment and importing it to our machine
# maybe it is a good idea to use dbredmine as mysql server
# anyway for now we are going to use localhost as mysql server
mysqldump -hdbredmine redmine_default > ~/redmine_production.sql
mysql -u redmine -predmine redmine < ~/redmine_production.sql

6. Configure gems

echo "gem: --no-rdoc --no-ri" > ~/.gemrc

7. Downloading and installing Redmine

wget -c http://rubyforge.org/frs/download.php/76255/redmine-1.4.4.tar.gz
tar xfz redmine-1.4.4.tar.gz
mv redmine-1.4.4 /usr/share/redmine
cd /usr/share/
chown -R root:root /usr/share/redmine
chown www-data /usr/share/redmine/config/environment.rb
ln -s /usr/share/redmine/public /var/www/redmine

8. Configuring Redmine

cp redmine/config/database.yml.example redmine/config/database.yml
vim redmine/config/database.yml
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: redmine
encoding: utf8
:wq
scp root@workflow-sandbox-vm.test.org:/usr/share/redmine/config/configuration.yml redmine/config/configuration.yml

9. Installing required gems for Redmine

gem install bundler
cd redmine
/var/lib/gems/1.8/bin/bundle install --without development test postgresql sqlite
ln -s /var/lib/gems/1.8/bin/rake /usr/bin/

10. Attachments

rm -fr /usr/share/redmine/files
mkdir -p /var/lib/redmine/default/files
ln -s /var/lib/redmine/default/files /usr/share/redmine/files
# copying attachments from production environment
rsync -avz --stats --progress root@10.99.0.241:/var/lib/redmine/default/files/*  /usr/share/redmine/files

11. Fixing permissions

mkdir public/plugin_assets
chown -R www-data:www-data files log tmp public/plugin_assets
chmod -R 755 files log tmp public/plugin_assets

12. Configuring Apache web server

vim /etc/apache2/sites-available/redmine
<VirtualHost *:443>
        ServerName workflow-vm.test.org
        ServerAlias workflow.test.org workflow
        DocumentRoot /var/www
 
        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/wildcard-internal-ca-test.org.crt
        SSLCertificateKeyFile /etc/apache2/ssl/wildcard-internal-ca-test.org.key
 
ServerAdmin ionut@vendio.ro
LogLevel warn
ErrorLog /var/log/apache2/redmine_error
CustomLog /var/log/apache2/redmine_access combined
<Directory /var/www/redmine>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
</Directory>
</VirtualHost>
:wq
vim /etc/apache2/ports.conf
:%s/NameVirtualHost \*:80/NameVirtualHost \*:443
:%s/Listen 80/#Listen 80
:wq
rsync -avz --stats --progress root@workflow-sandbox-vm.test.org:/etc/apache2/ssl /etc/apache2
 
mv /etc/apache2/sites-enabled/000-default /tmp
 
a2ensite redmine
a2enmod passenger
a2enmod ssl

13. Installing and migrating Redmine plugins

cd vendor/plugins

13.1. Question plugin

rsync -avz --stats --progress root@10.99.0.241:/usr/share/redmine/vendor/plugins/question_plugin /usr/share/redmine/vendor/plugins/
rsync -avz --stats --progress root@10.99.0.241:/usr/share/redmine/app/views/mailer/_issue_text* /usr/share/redmine/app/views/mailer/
mv /usr/share/redmine/app/views/mailer/_issue_text_html.rhtml /usr/share/redmine/app/views/mailer/_issue_text_html.erb
mv /usr/share/redmine/app/views/mailer/_issue_text_plain.rhtml /usr/share/redmine/app/views/mailer/_issue_text_plain.erb

13.2. Redmine Status plugin

rsync -avz --stats --progress root@workflow-sandbox-vm.test.org:/usr/share/redmine/vendor/plugins/redmine_status /usr/share/redmine/vendor/plugins/

13.3. Redmine Stuff to do plugin

rsync -avz --stats --progress root@workflow-sandbox-vm.test.org:/usr/share/redmine/vendor/plugins/stuff_to_do_plugin /usr/share/redmine/vendor/plugins/
rsync -avz --stats --progress root@workflow-sandbox-vm.test.org:/usr/share/redmine/lib/ar_condition.rb /usr/share/redmine/lib/

14. Fixing permissions for log file

cd /usr/share/redmine
chown www-data:www-data log/production.log

15. Final steps to get Redmine working

rake generate_session_store
rake db:migrate RAILS_ENV=production
rake db:migrate_plugins RAILS_ENV=production
rake tmp:cache:clear
rake tmp:sessions:clear

16. Restart Apache web server

/etc/init.d/apache2 restart

Files:
question plugin: question_plugin.tar.gz
redmine status plugin: redmine_status.tar.gz
stuff to do plugin: stuff_to_do_plugin.tar.gz

One thought on “Redmine – Upgrade to 1.4.4 on a debian squeeze”

Leave a Reply

Your email address will not be published. Required fields are marked *