torutkのブログ

ソフトウェア・エンジニアのブログ

Redmineのバージョンアップ(6.0→6.1)作業メモ

はじめに

Linuxサーバー(Rocky Linux 8)上で、Unicornアプリケーション(Rack)サーバーとNginx Webサーバーを用いた環境でRedmineを稼働しています。

この環境での Redmineバージョンアップ手順と問題対処などをメモしておきます。

Redmineのバージョンは、セマンティックバージョンに基づいて3桁の数値で指定されます。

バージョン番号の付与 - ソフトウェアエンジニアリング - Torutk

バージョンアップの際、どの桁の数値が上がるかで作業が変わります。今回は、稼働中のRedmine 6.0.2を先月リリースされた Redmine 6.1.0にバージョンアップするので、2桁目のマイナーバージョンが上がるマイナーバージョンアップとなります。

アップデート作業

Rubyバージョンの更新

Redmine 6.1のリリース情報から、Rubyの対応バージョンを確認します。Ruby 3.2、3.3および3.4に対応とあります。現在稼働しているサーバーのRubyバージョンを調べると

~$ ruby -v
ruby 3.1.7p261 (2025-03-26 revision 0a3704f218) [x86_64-linux]

残念ながら、対応バージョンから外れていました。というかRuby 3.1自体が 2025年3月でEOL(サポート終了)となっていました。

Rocky Linux 8で対応しているRubyのバージョンを確認すると、次のとおり Ruby 3.3を入れることが可能です。

~$ dnf module list ruby
Name  Stream   Profiles    Summary                                              
ruby  2.5 [d]  common [d]  An interpreter of object-oriented scripting language 
ruby  2.6      common [d]  An interpreter of object-oriented scripting language 
ruby  2.7      common [d]  An interpreter of object-oriented scripting language 
ruby  3.0      common [d]  An interpreter of object-oriented scripting language 
ruby  3.1 [e]  common [d]  An interpreter of object-oriented scripting language 
ruby  3.3      common [d]  An interpreter of object-oriented scripting language 

ヒント: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Rubyバージョンを変更すると、Rubyのgemパッケージ群も更新が必要になります。

まず Rubyの更新を実施します。

 ~$ sudo dnf module reset ruby -y
   :
~$ sudo dnf module enable ruby:3.3 -y
   :
 ~$ sudo dnf install ruby
   :

rubyに関係するOSパッケージの更新を実施します。

 ~$ sudo dnf update

Redmineの更新

更新前のRedmine 6.0は、git cloneにより /var/lib/redmine-6.0-stable に展開しています。Redmineの更新方法としては、cloneしたローカルディレクトリ上でブランチを6.1に切り替えるか、あらたに ブランチ6.1をgit cloneするかの方法があります。 今回は、Rubyも更新しているので、新たにgit cloneする方法とします。

~$ sudo git clone -b 6.1-stable https://github.com/redmine/redmine.git /var/lib/redmine-6.1-stable
  :
~$ sudo chown -R redmine:redmine /var/lib/redmine-6.1-stable/

新たにcloneしてきたので、設定ファイルをコピーしてきます。

redmine-6.1-stable$ cp ../redmine-6.0-stable/config/database.yml config/
redmine-6.1-stable$ cp ../redmine-6.0-stable/config/configuration.yml config/
redmine-6.1-stable$ cp ../redmine-6.0-stable/config.ru .
redmine-6.1-stable$ cp ../redmine-6.0-stable/config/unicorn.rb config/
  • config/routes.rb は、後で修正

Redmineが必要とするgem群をインストールします。

redmine-6.1-stable$ bundle config set --local path vendor/bundler
redmine-6.1-stable$ bundle config set --local without 'development test'
redmine-6.1-stable$ bundle config set --local force_ruby_platform true
  • config set で、/var/lib/redmine-6.1-stable/.bundle/config に設定が書かれます。
  • Nokogiri gemのインストールはデフォルトでglibc 2.29へのリンクを含みますが、Locky 8はglibc 2.28のためリンクエラーとなります。そこでgem インストール時にビルドを行うよう設定しています。

gemパッケージのインストールにネイティブビルドをするようになったら、commonmarker gemのインストールがエラーとなってしまいました。clang関係パッケージが必要となっています。

~$ sudo dnf install clang
  :
redmine-6.1-stable$ bundle install
  :

セッションデータ用クッキーの暗号化キー生成

redmine-6.1-stable$ bundle exec rails generate_secret_token

稼働中のRedmineを停止

~$ sudo systemctl stop redmine-unicorn

データベーススキーマの更新

redmine-6.1-stable$ bundle exec rails db:migrate RAILS_ENV=production

Unicornインストール

/var/lib/redmine-6.1-stable/Gemfile.local を作成

gem "unicorn"
gem "unicorn-worker-killer"
redmine-6.1-stable$ bundle update
~$ sudo ln -s /var/lib/redmine-6.1-stable /var/lib/redmine

/usr/lib/systemd/system/redmine-unicorn.serviceの修正

- WorkingDirectory=/var/lib/redmine-6.0-stable
+ WorkingDirectory=/var/lib/redmine-6.1-stable

- PIDFile=/var/lib/redmine-6.0-stable/tmp/pids/unicorn.pid
+ PIDFile=/var/lib/redmine-6.1-stable/tmp/pids/unicorn.pid
~$ sudo systemctl daemon-reload

添付ファイルの格納ディレクトリの移動

redmine-6.1-stable$ rm -rf file
redmine-6.1-stable$ mv ../redmine-6.0-stable/files/ .

プラグインのインストール

プラグインを各リポジトリからクローン

redmine-6.1-stable$ cd plugins/
plugins$ git clone https://github.com/agileware-jp/redmine_banner.git
  :
plugins$ git clone https://github.com/agileware-jp/redmine_issue_templates.git
  :
plugins$ git clone https://github.com/process91/redmine_latex_mathjax.git
  :
plugins$ git clone https://github.com/haru/redmine_theme_changer.git
  :
plugins$ git clone https://github.com/haru/redmine_wiki_extensions
  :
plugins$ git clone https://github.com/tkusukawa/redmine_wiki_lists.git
  :
plugins$ git clone https://github.com/onozaty/redmine-view-customize.git
  :
plugins$  git clone https://github.com/torutk/redmine_cozy_wiki_macros.git
  :
plugins$ git clone https://github.com/torutk/redmine_glossary.git
  :

必要なgemをインストール

redmine-6.1-stable$ bundle update
  :

データベースのマイグレーション実施

redmine-6.1-stable$ bundle exec rails redmine:plugins:migrate RAILS_ENV=production

テーマのインストール

redmine-6.1-stable$ git clone https://github.com/farend/redmine_theme_farend_bleuclair.git themes/bleuclair

デフォルトのページ設定

config/routes.rb

-  root :to => 'welcome#index'
-  root :to => 'welcome#index', :as => 'home'
+  root :to => 'wiki#show', :project_id => 'swe', :as => 'home'