Redmineについて



●Redmineのインストール

 参考URL:Redmine : インストール

 ApacheSMTPサーバPostgreSQL 10サーバRuby 2.5の設定は完了しているものとします。
 まず、必要なパッケージをインストールします。

EPEL, PowerTools からインストール
# dnf --enablerepo=epel,powertools -y install ruby-devel postgresql-server-devel openssl-devel libxslt-devel libxml2-devel libpq-devel libcurl-devel libyaml-devel zlib-devel httpd-devel gcc gcc-c++ gcc-gdb-plugin make patch rpm-build ImageMagick ImageMagick-devel


 Redmine用のユーザとデータベースを作成しておきます。
# vi /var/lib/pgsql/data/pg_hba.conf
以下のように変更
#host    all             all             127.0.0.1/32            ident
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

# systemctl restart postgresql
# su - postgres
$ createuser redmine
$ createdb redmine -O redmine
$ psql -c "alter user redmine with password 'paswsword'"
ALTER ROLE
$ exit
 Redmineをダウンロードしてインストールします。最新版を確認してダウンロードしてください。
# curl -O https://www.redmine.org/releases/redmine-5.0.1.tar.gz
# tar zxvf redmine-5.0.1.tar.gz
# mkdir /var/www/redmine
# mv redmine-5.0.1 /var/www/redmine
# rmdir redmine-5.0.1
# cd /var/www/redmine
# vi config/database.yml
新規作成
production:
  adapter: postgresql
  # データベース名
  database: redmine
  host: localhost
  # データベースユーザ
  username: redmine
  # データベースユーザのパスワード
  password: password
  encoding: utf8

# vi config/configuration.yml
新規作成 (SMTPの設定)
production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: "localhost"
      port: 25
      domain: 'bigbang.mydns.jp'
  rmagick_font_path: /usr/share/fonts/google-droid/DroidSansJapanese.ttf

bundler インストール
# gem install bundler --no-rdoc --no-ri
※エラーが表示される場合、下記を実行
# gem install bundler

Redmineで使用するGemをインストール
# bundle install --without development test mysql sqlite

秘密鍵の生成
# bundle exec rake generate_secret_token

テーブル生成
# bundle exec rake db:migrate RAILS_ENV=production

Passengerインストール
# gem install passenger --no-rdoc --no-ri
※エラーが表示される場合、下記を実行
# gem install passenger

Apache httpd用モジュールインストール
# passenger-install-apache2-module

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.
1

--------------------------------------------

Which languages are you interested in?

Use <space> to select.
If the menu doesn't display correctly, press '!'

 ‣ ⬢  Ruby
   ⬡  Python
   ⬡  Node.js
   ⬡  Meteor
(Enterキー押下)
  :
(途中省略)
  :
--------------------------------------------
Almost there!

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
   <IfModule mod_passenger.c>
     PassengerRoot /usr/local/share/gems/gems/passenger-6.0.14
     PassengerDefaultRuby /usr/bin/ruby
   </IfModule>

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!

Press ENTER when you are done editing.
(Enterキー押下)
  :
(途中省略)
  :
--------------------------------------------

Deploying a web application

To learn how to deploy a web app on Passenger, please follow the deployment
guide:

  https://www.phusionpassenger.com/library/deploy/apache/deploy/

Enjoy Phusion Passenger, a product of Phusion® (www.phusion.nl) :-)
https://www.phusionpassenger.com

Passenger® is a registered trademark of Phusion Holding B.V.


●httpアクセス(80番ポート)兼URLのルートで公開する方法

 Passengerを実行するためのhttpdの設定例です。
# vi /etc/httpd/conf.d/redmine.conf
# Redmine Data Access Setting

NameVirtualHost *:80
<VirtualHost *:80>
  ServerName www.bigbang.mydns.jp
  DocumentRoot /var/www/redmine/public
</VirtualHost>

<Directory "/var/www/redmine/public">
  Options FollowSymLinks
  AllowOverride All
</Directory>

# Redmine Passenger Setting

LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/share/gems/gems/passenger-6.0.14
PassengerDefaultRuby /usr/bin/ruby
SetEnv LD_LIBRARY_PATH /usr/lib64
RailsBaseURI /redmine

# Passenger Option Settings
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 864000
PassengerStatThrottleRate 10

# End of File
Header always unset "X-Powerd-By"
Header always unset "X-Runtime"

# chown -R apache. /var/www/redmine
# systemctl restart httpd
 ブラウザで http://www.bigbang.mydns.jp/ にアクセスすると表示されます。

●httpsアクセス(443番ポート)兼URLのルートで公開する方法

 Passengerを実行するためのhttpdの設定例で、かつ、Let's Encrypt証明書の設定は完了しているものとします。
# vi /etc/httpd/conf.d/redmine.conf
# Redmine Data Access Setting

NameVirtualHost *:443
<VirtualHost *:443>
  SSLEngine On
  SSLProtocol all -SSLv2
  SSLCertificateFile /etc/letsencrypt/live/www.bigbang.mydns.jp/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/www.bigbang.mydns.jp/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/www.bigbang.mydns.jp/chain.pem

  ServerName www.bigbang.mydns.jp
  DocumentRoot /var/www/redmine/public
</VirtualHost>

<Directory "/var/www/redmine/public">
  Options FollowSymLinks
  AllowOverride All
</Directory>

# Redmine Passenger Setting

LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/share/gems/gems/passenger-6.0.14
PassengerDefaultRuby /usr/bin/ruby
SetEnv LD_LIBRARY_PATH /usr/lib64
RailsBaseURI /redmine

# Passenger Option Settings
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 864000
PassengerStatThrottleRate 10

# End of File
Header always unset "X-Powerd-By"
Header always unset "X-Runtime"

# chown -R apache. /var/www/redmine
# systemctl restart httpd
 ブラウザで https://www.bigbang.mydns.jp/ にアクセスすると表示されます。

●httpsアクセス(443番ポート)兼URLのルートではなく、/redmineで公開する方法

 Passengerを実行するためのhttpdの設定例で、かつ、Let's Encrypt証明書の設定は完了しているものとします。
# vi /etc/httpd/conf.d/redmine.conf
# Redmine Data Access Setting

NameVirtualHost *:443
<VirtualHost *:443>
  SSLEngine On
  SSLProtocol all -SSLv2
  SSLCertificateFile /etc/letsencrypt/live/www.bigbang.mydns.jp/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/www.bigbang.mydns.jp/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/www.bigbang.mydns.jp/chain.pem
</VirtualHost>

<Directory "/var/www/redmine/public">
  Options FollowSymLinks
  AllowOverride All
</Directory>

# Redmine Passenger Setting

LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/share/gems/gems/passenger-6.0.14
PassengerDefaultRuby /usr/bin/ruby
SetEnv LD_LIBRARY_PATH /usr/lib64
RailsBaseURI /redmine

# Passenger Option Settings
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 864000
PassengerStatThrottleRate 10

# End of File
Header always unset "X-Powerd-By"
Header always unset "X-Runtime"

/etc/httpd/conf/httpd.confのDocumentRootが/var/www/htmlの場合、下記のようにシンボリックシンクを作成します。

# ln -s /var/www/redmine/public /var/www/html/redmine

# chown -R apache. /var/www/redmine
# systemctl restart httpd
 ブラウザで https://www.bigbang.mydns.jp/redmine/ にアクセスすると表示されます。

●Redmineのインストール(MariaDBを使用)

 参考URL:Redmine 3.1をCentOS 7.1にインストールする手順
 参考URL:Redmineのインストール

 既に「●Redmineのインストール」でPostgreSQLを使用してRedmineを構築済み(https://www.bigbang.mydns.jp/redmine/)です。
 この状態でMariaDBを使用してRedmineを立ち上げたいと思います。
 なお、この時のURLをhttps://www.bigbang.mydns.jp/redmine2/とします。
 また、MariaDBはインストール(「●初期設定(CentOS 8)」)済みとします。
 Redmine用データベースを作成します。
# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 914
Server version: 10.3.32-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE data_redmine CHARACTER SET utf8mb4;
Query OK, 1 row affected (0.002 sec)

MariaDB [(none)]> CREATE USER 'redmine'@'localhost' IDENTIFIED BY '**********';
Query OK, 0 rows affected (0.019 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON data_redmine.* TO 'redmine'@'localhost';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> exit
Bye
 redmineでMariaDBに接続します。
# mysql -u redmine -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 927
Server version: 10.3.32-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| data_redmine       |
| information_schema |
+--------------------+
2 rows in set (0.002 sec)

MariaDB [(none)]> exit
Bye

$ su -
パスワード:
 OS上にアカウントを作成し、メールを受信できるようにします。
# useradd hogehoge
[root@serverA redmine2]# passwd hogehoge
Changing password for user hogehoge.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

# exit
 $HOME/Maildir/に受信メールが保存されるように、Procmailを設定します。
$ su - hogehoge
パスワード:
[hogehoge@serverA ~]$ vi .procmailrc
SHELL=/bin/bash
PATH=$HHOME/bin:/usr/bin:/usr/local/sbin
MAILDIR=
DEFAULT=$MAILDIR
LOGFILE=$HOME/procmail.log

##### メールの振り分け #####
#:0
#* ^Subject:.*AIDE
#$MAILDIR/.AIDE/
#

##### 宣伝・広告メール対策 #####
:0 
* ^Subject:.*iso-2022-jp
* ^Subject:.*\/.*
* ? echo "$MATCH" | nkf -meZ2 | sed 's/[[:space:]]//g' | egrep '未承諾広告'
/dev/null

 アカウントhogehogeからメール送信が出来るか確認します。

 Redmine(MariaDB利用)を準備します。
# dnf install -y mariadb-devel
# cd /usr/local/src
# curl -O https://www.redmine.org/releases/redmine-5.0.1.tar.gz
# tar zxvf redmine-5.0.1.tar.gz
# mv redmine-5.0.1 /var/www/redmine2
# cd /var/www/redmine2

# vi config/database.yml
production:
  adapter: mysql2
  # データベース名
  database: data_redmine
  host: localhost
  # データベースユーザ
  username: redmine
  # データベースユーザのパスワード
  password: **********
  encoding: utf8

# vi config/configuration.yml
production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: localhost
      port: 587
      domain: bigbang.mydns.jp
      authentication: :login
      user_name: redmine
      password: **********
      enable_starttls_auto: true
      openssl_verify_mode: none
  rmagick_font_path: /usr/share/fonts/google-droid/DroidSansJapanese.ttf
 先にPostgreSQL利用のRedmineを設定していたので、MySQLを利用できるようにGemをインストールします。
※Redmineがインストールされているディレクトリ(/var/www/redmine2)に移動後、実施してください。
# cd /var/www/redmine2

# bundle install --without development test sqlite

秘密鍵の生成
# bundle exec rake generate_secret_token

テーブル生成
# bundle exec rake db:migrate RAILS_ENV=production

 Passengerインストール(未実施)
 # gem install passenger --no-rdoc --no-ri
  ※エラーが表示される場合、下記を実行
  # gem install passenger

 Apache httpd用モジュールインストール(未実施)
 # passenger-install-apache2-module

# vi /etc/httpd/conf.d/redmine2.conf
# Redmine Data Access Setting

<Directory "/var/www/redmine2/public">
  Options FollowSymLinks
  AllowOverride All
</Directory>

# Redmine Passenger Setting

LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/share/gems/gems/passenger-6.0.14
PassengerDefaultRuby /usr/bin/ruby
SetEnv LD_LIBRARY_PATH /usr/lib64
RailsBaseURI /redmine2 ← BaseURLを間違えるとファイルが一覧表示されてしまいます。 

# Passenger Option Settings
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 864000
PassengerStatThrottleRate 10

# End of File
Header always unset "X-Powerd-By"
Header always unset "X-Runtime"

# ln -s /var/www/redmine2/public /var/www/html/redmine2

# chown -R apache. /var/www/redmine2
# systemctl restart httpd
 ブラウザで http://www.bigbang.mydns.jp/redmine2/ にアクセスすると表示されます。

●メールが送信されない

 動作確認として「パスワードの再設定」でメール送信しようとしたところ下記のようにエラーとなり、送信することができませんでした。

2022/05/25 15:42:09 serverA postfix/smtpd[2417909]: connect from serverA[127.0.0.1]
2022/05/25 15:42:09 serverA postfix/smtpd[2417909]: discarding EHLO keywords: CHUNKING
2022/05/25 15:42:09 serverA postfix/smtpd[2417909]: SSL_accept error from serverA[127.0.0.1]: -1
2022/05/25 15:42:09 serverA postfix/smtpd[2417909]: warning: TLS library problem: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:1544:SSL alert number 80:
2022/05/25 15:42:09 serverA postfix/smtpd[2417909]: lost connection after STARTTLS from serverA[127.0.0.1]
2022/05/25 15:42:09 serverA postfix/smtpd[2417909]: disconnect from serverA[127.0.0.1] ehlo=1 starttls=0/1 commands=1/2


 まず、Redmineからの送信元となるメールアドレスをデフォルトから変更するため、管理者権限でログインします。
 管理 ー 設定 ー メール通知 ー 送信元メールアドレス
 「redmine@example.net」を送信可能な任意のメールアドレスに変更し、保存します。
 この時点で送信できるか確認するため、右下の「テストメール送信」をクリックします。
 エラー内容はRedmineページの上部に表示されます。
 エラーとなった時の/var/log/maillogの内容は下記のとおりです(上記エラーと同様)。

2022/05/25 16:48:00 serverA postfix/smtpd[2416463]: connect from serverA[127.0.0.1]
2022/05/25 16:48:00 serverA postfix/smtpd[2416463]: discarding EHLO keywords: CHUNKING
2022/05/25 16:48:00 serverA postfix/smtpd[2416463]: SSL_accept error from serverA[127.0.0.1]: -1
2022/05/25 16:48:00 serverA postfix/smtpd[2416463]: warning: TLS library problem: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:1544:SSL alert number 80:
2022/05/25 16:48:00 serverA postfix/smtpd[2416463]: lost connection after STARTTLS from serverA[127.0.0.1]
2022/05/25 16:48:00 serverA postfix/smtpd[2416463]: disconnect from serverA[127.0.0.1] ehlo=1 starttls=0/1 commands=1/2


 メール送信時のOpenSSLに関するエラーなので、configuration.ymlを修正します。
# vi /var/www/redmine/config/configuration.yml
production:
  email_delivery:
    delivery_method: :smtp
    smtp_settings:
      address: localhost
      port: 587
      authentication: :login
      domain: bigbang.mydns.jp
      user_name: redmine
      password: (任意のパスワード)
      enable_starttls_auto: true
      openssl_verify_mode: none
  rmagick_font_path: /usr/share/fonts/google-droid/DroidSansJapanese.ttf

# systemctl restart httpd
 いろいろ苦労しましたが、上記の設定で無事メール送信できるようになりました。

●データの移行方法

 参考URL:既存のRedmine環境の引っ越し - その3. 旧環境からデータを移行する
 参考URL:【1.3.0 → 4.1.0.stable】Bitnami Redmineのサーバー移行&バージョンアップデート!【引っ越し】
 参考URL:アップグレード

 移行前のサーバにログインし、database.ymlに記載されている接続情報を使用してmysqldumpでデータを出力します。
$ mysqldump -u redmine -p -t old_redmine_table > OUTPUT_FILE_NAME
 次にダンプしたファイルをscpで移行先の環境のRedmineコンテナにアップして、移行先環境でこのデータを読み込ませます。
$ mysql -u redmine -p password new_redmine_table < /tmp/OUTPUT_FILE_NAME
ERROR 1273 (HY000) at line 25: Unknown collation: 'utf8mb4_0900_ai_ci'
 エラー(Unknown collation: 'utf8mb4_0900_ai_ci')が表示されましたので、viを使用して修正します。
$ vi /tmp/OUTPUT_FILE_NAME

一括変換
:s/utf8mb4_0900_ai_ci/utf8mb4_0900_ai_ci/g
 再度、移行先環境でデータを読み込ませます。
 エラーが表示されなければ、正常に読み込まれたことになります。
 Redmineのインストールディレクトリ(/var/www/redmine2/)へ移動しマイグレーションコマンドを実行します。
データベース更新
$ bundle exec rake db:migrate RAILS_ENV=production
※この作業により、Redmine情報の「すべてのデータベースマイグレーションが実行済」が有効化(チェックマーク)になった。

クリーンアップ
$ bundle exec rake tmp:cache:clear RAILS_ENV=production
 最後にApacheを再起動します。
# systemctl restart httpd
 Apacheを再起動しないと「Internal Error」となり、Redmineを利用できません。

●忘失した管理者のパスワードを強制変更するには

 参考URL:Redmineの管理者パスワード忘れた

 Redmineの管理者のパスワードを忘れてしまった場合の一般的な変更方法は下記のとおりです。

 adminユーザーのパスワードをリセットする

 しかし、自分が管理者でない場合や管理者のアカウント情報(メールアドレス等)が不明な場合、データベースを直接編集することにより変更できます。
 下記のように実施することにより、管理者(admin)のパスワードを強制的に変更できます。
対象のデータベースに接続
$ mysql -u root -p
Enter password: 

MariaDB [(none)]> use redmine;

管理者(admin)のパスワード情報確認
MariaDB [redmine]> select id,login,hashed_password,salt from users where id = '1';
+----+-------+-----------------+------------+
| id | login | hashed_password | salt       |
+----+-------+-----------------+------------+
|  1 | admin | pppppppppp      | SSSSSSSSSS |
+----+-------+-----------------+------------+
1 row in set (0.002 sec)
 上記のハッシュパスワード(pppppppppp)部分を書き換えます。
 adminをSHA1でハッシュ計算すると「d033e22ae348aeb5660fc2140aec35850c4da997」になります。
$ echo -n 'admin' | shasum -a 1
d033e22ae348aeb5660fc2140aec35850c4da997  -
 これにsalt(SSSSSSSSSS)を加えて「SSSSSSSSSSd033e22ae348aeb5660fc2140aec35850c4da997」として、SHA1でハッシュ計算すると「ac27073506f16c273e279baa00452b362cd37018」となります。
$ echo -n 'SSSSSSSSSSd033e22ae348aeb5660fc2140aec35850c4da997' | shasum -a 1
ac27073506f16c273e279baa00452b362cd37018  -
 これをハッシュパスワード部分に書き込みます。
MariaDB [redmine]> update users set hashed_password="ac27073506f16c273e279baa00452b362cd37018" where id='1';
Query OK, 1 row affected (0.006 sec)
Rows matched: 1  Changed: 1  Warnings: 0
 これでRedmineにadmin/adminでログインできるようになります。

●We're sorry, but something went wrong.

 参考URL:【Redmine】We're sorry, but something went wrong.(Gemfile.lock編)

 Redmine(5.0.1)のアップデート作業のため、Redmine(5.0.4)を展開しインストール(/var/www/redmine-5.0.4)してアップデートの準備をしていました。
 試しに/var/www/redmine-5.0.4に移動後、下記コマンド実行しました。
# gem install bundler --no-rdoc --no-ri
# bundle install --without development test sqlite
 OSを再起動し、Redmine(5.0.1)のページにアクセスすると「We're sorry, but something went wrong.」のエラーが表示されるようになってしまいました。
 ログ(/var/log/httpd/error_log)を確認すると、下記のようなエラーが気になりました。

App 14518 output: /usr/local/share/gems/gems/passenger-6.0.14/src/helper-scripts/rack-preloader.rb:29:in `<main>'
[ E 2023-01-06 08:06:37.1331 14109/Tt age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/redmine: The application encountered the following error: You have already activated strscan 3.0.5, but your Gemfile requires strscan 3.0.3. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
Error ID: 871f5d1b
Error details saved to: /tmp/passenger-error-KrhvxR.html


 /var/www/redmineにあるGemfile.lockの内容を確認すると、「strscan (3.0.3)」という行がありました。
 これを「strscan (3.0.5)」に変更し、httpdを再起動すると正常にアクセスできるようになりました。
 
●ImageMagickのPDFサポートが利用可能 (オプション)がエラーになる

 参考URL:Redmine/情報 - バージョン 4.1.0

 「ImageMagickのPDFサポートが利用可能 (オプション)」をOKにするには、Ghostscriptをインストールします。
# dnf install ghostscript -y
# systemctl restart httpd
 これで「ImageMagickのPDFサポートが利用可能 (オプション)」がOKとなります。

●Redmineを5.0.1から5.0.4へアップデート(その1)

 参考URL:Step 3 - アップグレードの実行
 参考URL:[Redmine] 4.1.0から4.2.1へアップグレードする手順

 結論:現環境のままでは、Redmineを5.0.1から5.0.4にアップデートすることは出来ませんでした。

 動作中の環境は下記のとおりです。
# ruby -v
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]

# bundle -v
Bundler version 2.3.14

# gem -v
2.7.6.3

# rails -v
Rails 6.1.7

# lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	Rocky
Description:	Rocky Linux release 8.7 (Green Obsidian)
Release:	8.7
Codename:	GreenObsidian
 Redmine 5.0.4をダウンロードし、インストールします。
# cd /usr/local/src
# wget https://www.redmine.org/releases/redmine-5.0.4.tar.gz
ハッシュ値を確認します。
# sha256sum redmine-5.0.4.tar.gz
# tar xvf redmine-5.0.4.tar.gz
# mv /usr/local/src/redmine-5.0.4 /var/www/redmine_up
# chown -R apache. /var/www/redmine_up
 古い環境から、データベースの設定ファイルとRedmineの設定ファイルをコピーします。
# cp -a /var/www/redmine/config/database.yml /var/www/redmine-5.0.4/config/
# cp -a /var/www/redmine/config/configuration.yml /var/www/redmine-5.0.4/config/
 filesディレクトリを、新しい環境にコピーします。
# cp -rp /var/www/redmine/files/* /var/www/redmine_up/files/
 使用しているプラグインがある場合、プラグインをコピーします。
 例えば、View Customizeというプラグインを使用している場合、下記のようにプラグインをコピーします。
# cp -ar /var/www/redmine/plugins/view_customize /var/www/redmine-5.0.4/plugins/
 新しいRedmineのセットアップを行います。

 新しいRedmineを展開したディレクトリで実行する必要があります。
# cd /var/www/redmine_up

Redmineで使用するGemをインストール
# bundle install --without development test mysql sqlite
 :  : Installing psych 5.0.1 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /usr/share/gems/gems/psych-5.0.1/ext/psych /usr/bin/ruby -r ./siteconf20230106-32803-1gznslc.rb extconf.rb checking for yaml.h... no yaml.h not found *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You mayVneed configuration options.  :  : An error occurred while installing psych (5.0.1), and Bundler cannot continue. In Gemfile: psych
 エラーとなりました。
 「yaml.h not found」ということですので、libyaml-develをインストールします。
# dnf install libyaml-devel
 再度、実行します。
# bundle install --without development test mysql sqlite
 インストールできました。
秘密鍵の生成
# bundle exec rake generate_secret_token
/usr/share/gems/gems/psych-5.0.1/lib/psych/versions.rb:5: warning: already initialized constant Psych::VERSION /usr/share/ruby/psych/versions.rb:4: warning: previous definition of VERSION was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:7: warning: already initialized constant Psych::ClassLoader::BIG_DECIMAL /usr/share/ruby/psych/class_loader.rb:7: warning: previous definition of BIG_DECIMAL was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:8: warning: already initialized constant Psych::ClassLoader::COMPLEX /usr/share/ruby/psych/class_loader.rb:8: warning: previous definition of COMPLEX was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:9: warning: already initialized constant Psych::ClassLoader::DATE /usr/share/ruby/psych/class_loader.rb:9: warning: previous definition of DATE was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:10: warning: already initialized constant Psych::ClassLoader::DATE_TIME /usr/share/ruby/psych/class_loader.rb:10: warning: previous definition of DATE_TIME was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:11: warning: already initialized constant Psych::ClassLoader::EXCEPTION /usr/share/ruby/psych/class_loader.rb:11: warning: previous definition of EXCEPTION was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:12: warning: already initialized constant Psych::ClassLoader::OBJECT /usr/share/ruby/psych/class_loader.rb:12: warning: previous definition of OBJECT was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:13: warning: already initialized constant Psych::ClassLoader::PSYCH_OMAP /usr/share/ruby/psych/class_loader.rb:13: warning: previous definition of PSYCH_OMAP was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:14: warning: already initialized constant Psych::ClassLoader::PSYCH_SET /usr/share/ruby/psych/class_loader.rb:14: warning: previous definition of PSYCH_SET was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:15: warning: already initialized constant Psych::ClassLoader::RANGE /usr/share/ruby/psych/class_loader.rb:15: warning: previous definition of RANGE was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:16: warning: already initialized constant Psych::ClassLoader::RATIONAL /usr/share/ruby/psych/class_loader.rb:16: warning: previous definition of RATIONAL was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:17: warning: already initialized constant Psych::ClassLoader::REGEXP /usr/share/ruby/psych/class_loader.rb:17: warning: previous definition of REGEXP was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:18: warning: already initialized constant Psych::ClassLoader::STRUCT /usr/share/ruby/psych/class_loader.rb:18: warning: previous definition of STRUCT was here /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:19: warning: already initialized constant Psych::ClassLoader::SYMBOL /usr/share/ruby/psych/class_loader.rb:19: warning: previous definition of SYMBOL was here rake aborted! SyntaxError: (eval):2: syntax error, unexpected =>, expecting '}' load {"Exception"=>Exception, "Object"=>Object, ... ^~ (eval):2: dynamic constant assignment load {"Exception"=>Exception, "Object"=>Object, "Psych::Om... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...ception"=>Exception, "Object"=>Object, "Psych::Omap"=>Psych:... ... ^~ (eval):2: dynamic constant assignment ..."=>Exception, "Object"=>Object, "Psych::Omap"=>Psych::Omap, ... ... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...bject"=>Object, "Psych::Omap"=>Psych::Omap, "Psych::Set"=>Ps... ... ^~ (eval):2: dynamic constant assignment ...ct, "Psych::Omap"=>Psych::Omap, "Psych::Set"=>Psych::Set, "R... ... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...p"=>Psych::Omap, "Psych::Set"=>Psych::Set, "Range"=>Range, "... ... ^~ (eval):2: dynamic constant assignment ...Omap, "Psych::Set"=>Psych::Set, "Range"=>Range, "Rational"=>... ... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...ch::Set"=>Psych::Set, "Range"=>Range, "Rational"=>Rational, ... ... ^~ (eval):2: dynamic constant assignment ...t"=>Psych::Set, "Range"=>Range, "Rational"=>Rational, "Struc... ... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...t, "Range"=>Range, "Rational"=>Rational, "Struct"=>Struct, "... ... ^~ (eval):2: dynamic constant assignment ..."=>Range, "Rational"=>Rational, "Struct"=>Struct, "Symbol"=>... ... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...Rational"=>Rational, "Struct"=>Struct, "Symbol"=>Symbol, "Re... ... ^~ (eval):2: dynamic constant assignment ...l"=>Rational, "Struct"=>Struct, "Symbol"=>Symbol, "Regexp"=>... ... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...l, "Struct"=>Struct, "Symbol"=>Symbol, "Regexp"=>Regexp, "Co... ... ^~ (eval):2: dynamic constant assignment ...uct"=>Struct, "Symbol"=>Symbol, "Regexp"=>Regexp, "Complex"=... ... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ...t, "Symbol"=>Symbol, "Regexp"=>Regexp, "Complex"=>Complex} ... ^~ (eval):2: dynamic constant assignment ...bol"=>Symbol, "Regexp"=>Regexp, "Complex"=>Complex} ... ^ (eval):2: syntax error, unexpected =>, expecting &. or :: or '[' or '.' ..., "Regexp"=>Regexp, "Complex"=>Complex} ... ^~ /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:38:in `class_eval' /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:38:in `block in <class:ClassLoader>' /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:36:in `each' /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:36:in `<class:ClassLoader>' /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:6:in `<module:Psych>' /usr/share/gems/gems/psych-5.0.1/lib/psych/class_loader.rb:5:in `<top (required)>' /usr/share/gems/gems/psych-5.0.1/lib/psych/nodes/node.rb:3:in `require_relative' /usr/share/gems/gems/psych-5.0.1/lib/psych/nodes/node.rb:3:in `<top (required)>' /usr/share/gems/gems/psych-5.0.1/lib/psych/nodes.rb:2:in `require_relative' /usr/share/gems/gems/psych-5.0.1/lib/psych/nodes.rb:2:in `<top (required)>' /usr/share/gems/gems/psych-5.0.1/lib/psych.rb:15:in `require_relative' /usr/share/gems/gems/psych-5.0.1/lib/psych.rb:15:in `<top (required)>' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/runtime.rb:60:in `require' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/runtime.rb:60:in `block (2 levels) in require' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/runtime.rb:55:in `each' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/runtime.rb:55:in `block in require' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/runtime.rb:44:in `each' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/runtime.rb:44:in `require' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler.rb:176:in `require' /var/www/redmine_up/config/application.rb:18:in `<top (required)>' /var/www/redmine_up/Rakefile:5:in `require' /var/www/redmine_up/Rakefile:5:in `<top (required)>' /usr/share/gems/gems/rake-13.0.6/exe/rake:27:in `<top (required)>' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:58:in `load' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:58:in `kernel_load' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:23:in `run' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/cli.rb:483:in `exec' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/cli.rb:31:in `dispatch' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/cli.rb:25:in `start' /usr/local/share/gems/gems/bundler-2.3.14/exe/bundle:48:in `block in <top (required)>' /usr/local/share/gems/gems/bundler-2.3.14/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors' /usr/local/share/gems/gems/bundler-2.3.14/exe/bundle:36:in `<top (required)>' /usr/local/bin/bundle:23:in `load' /usr/local/bin/bundle:23:in `<main>' (See full trace by running task with --trace)
 現環境のままでは、Redmineを5.0.1から5.0.4にアップデートすることは出来ませんでした。

●Redmine 5.0.4はどの環境で動作するのかの確認

 古いRedmineはインストールされていません。

 Ruby 2.6はサポートが切れている(2023.1.10現在、参考:Rubyのサポート・ライフサイクルとEOL)ので、2.7を選択しました。

 Rubyは2.7.6、PostgreSQLは13をインストール。
 その後、Redmineの設定作業を実施し、Redmineに接続できました。

 更に、Rubyは2.7.6、PostgreSQLは10.21にダウングレードしてみます。
 こちらも問題なくRedmineに接続できました。

●Redmineを5.0.1から5.0.4へアップデート(その2):Ruby 2.6を選択

 参考URL:Step 3 - アップグレードの実行
 参考URL:[Redmine] 4.1.0から4.2.1へアップグレードする手順

 Redmine(5.0.4) + Ruby(2.6.10)で正常に動作することを確認
 Redmine(5.0.4) + Ruby(2.7.6)で正常に動作することを確認

 こちらの方法は、rbenvを作業ユーザ(root)のホームディレクトリにインストールする方法となっています。
 したがって、ちょっとした工夫をしないと公開することができません。 
 rbenvのインストール先を指定してインストールする場合(推奨)は「●Redmineを5.0.1から5.0.4へアップデート(その3):Ruby 2.7.6を選択」を参照してください。

 動作中の環境は下記のとおりです。
# ruby -v
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]

# bundle -v
Bundler version 2.3.14

# gem -v
2.7.6.3

# rails -v
Rails 6.1.7

# lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	Rocky
Description:	Rocky Linux release 8.7 (Green Obsidian)
Release:	8.7
Codename:	GreenObsidian
 インストールされているRubyのバージョンが2.5.9なので、これを削除し2.6.10をインストールします。・・・
 ①を実施せず、dnf module intallコマンドでRuby 2.6をインストールせず、かつ、rbenv installコマンドでRuby 2.6をインストールする方法でも動作することを確認できました。
①の場合、下記コマンドは実施しない
# dnf module list ruby
Rocky Linux 8 - AppStream
Name              Stream                 Profiles                   Summary                                                         
ruby              2.5 [d][e]             common [d] [i]             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                    common [d]                 An interpreter of object-oriented scripting language            

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

①の場合、下記コマンドは実施しない
# dnf module reset ruby -y
依存関係が解決しました。
====================================================================================================================================
 パッケージ                     アーキテクチャー              バージョン                       リポジトリー                   サイズ
====================================================================================================================================
モジュールプロファイルの無効化中:
 ruby/common                                                                                                                       
モジュールの再設定中:
 ruby                                                                                                                              

トランザクションの概要
====================================================================================================================================

完了しました!

①の場合、下記コマンドは実施しない
Ruby 2.5を削除
# dnf remove ruby -y

①の場合、下記コマンドは実施しない
# dnf module enable ruby:2.6 -y
依存関係が解決しました。
====================================================================================================================================
 パッケージ                     アーキテクチャー              バージョン                       リポジトリー                   サイズ
====================================================================================================================================
モジュールストリームの有効化中:
 ruby                                                         2.6                                                                  

トランザクションの概要
====================================================================================================================================

完了しました!

①の場合、下記コマンドは実施しない
# dnf module list ruby
Rocky Linux 8 - AppStream
Name               Stream                Profiles                 Summary                                                           
ruby               2.5 [d]               common [d]               An interpreter of object-oriented scripting language              
ruby               2.6 [e]               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                   common [d]               An interpreter of object-oriented scripting language              

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

①の場合、下記コマンドは実施しない
# dnf module install ruby -y
依存関係が解決しました。 ==================================================================================================================================== パッケージ アーキテクチャー バージョン リポジトリー サイズ ==================================================================================================================================== アップグレード: ruby x86_64 2.6.10-109.module+el8.6.0+988+8031c193 appstream 87 k ruby-devel x86_64 2.6.10-109.module+el8.6.0+988+8031c193 appstream 243 k ruby-libs x86_64 2.6.10-109.module+el8.6.0+988+8031c193 appstream 3.0 M rubygem-bigdecimal x86_64 1.4.1-109.module+el8.6.0+988+8031c193 appstream 100 k rubygem-io-console x86_64 0.4.7-109.module+el8.6.0+988+8031c193 appstream 67 k rubygem-psych x86_64 3.1.0-109.module+el8.6.0+988+8031c193 appstream 96 k rubygem-rdoc noarch 6.1.2.1-109.module+el8.6.0+988+8031c193 appstream 456 k rubygems noarch 3.0.3.1-109.module+el8.6.0+988+8031c193 appstream 315 k 依存関係のインストール: rubygem-irb noarch 1.0.0-109.module+el8.6.0+988+8031c193 appstream 111 k 置き換え ruby-irb.noarch 2.5.9-110.module+el8.6.0+992+fc951c18 ダウングレード: rubygem-json x86_64 2.1.0-109.module+el8.6.0+988+8031c193 appstream 90 k rubygem-openssl x86_64 2.1.2-109.module+el8.6.0+988+8031c193 appstream 189 k モジュールプロファイルのインストール中: ruby/common トランザクションの概要 ==================================================================================================================================== インストール 1 パッケージ アップグレード 8 パッケージ ダウングレード 2 パッケージ ダウンロードサイズの合計: 4.7 M パッケージのダウンロード: (1/11): rubygem-openssl-2.1.2-109.module+el8.6.0+988+8031c193.x86_64.rpm 2.1 MB/s | 189 kB 00:00 (2/11): rubygem-json-2.1.0-109.module+el8.6.0+988+8031c193.x86_64.rpm 702 kB/s | 90 kB 00:00 (3/11): rubygem-irb-1.0.0-109.module+el8.6.0+988+8031c193.noarch.rpm 851 kB/s | 111 kB 00:00 (4/11): ruby-2.6.10-109.module+el8.6.0+988+8031c193.x86_64.rpm 1.9 MB/s | 87 kB 00:00 (5/11): rubygem-bigdecimal-1.4.1-109.module+el8.6.0+988+8031c193.x86_64.rpm 25 MB/s | 100 kB 00:00 (6/11): ruby-devel-2.6.10-109.module+el8.6.0+988+8031c193.x86_64.rpm 6.5 MB/s | 243 kB 00:00 (7/11): rubygem-psych-3.1.0-109.module+el8.6.0+988+8031c193.x86_64.rpm 5.5 MB/s | 96 kB 00:00 (8/11): rubygem-io-console-0.4.7-109.module+el8.6.0+988+8031c193.x86_64.rpm 1.1 MB/s | 67 kB 00:00 (9/11): rubygem-rdoc-6.1.2.1-109.module+el8.6.0+988+8031c193.noarch.rpm 8.8 MB/s | 456 kB 00:00 (10/11): rubygems-3.0.3.1-109.module+el8.6.0+988+8031c193.noarch.rpm 7.4 MB/s | 315 kB 00:00 (11/11): ruby-libs-2.6.10-109.module+el8.6.0+988+8031c193.x86_64.rpm 24 MB/s | 3.0 MB 00:00 ------------------------------------------------------------------------------------------------------------------------------------ 合計 18 MB/s | 4.7 MB 00:00 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中 準備 : 1/1 アップグレード中 : ruby-libs-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 1/22 ダウングレード中 : rubygem-openssl-2.1.2-109.module+el8.6.0+988+8031c193.x86_64 2/22 インストール中 : rubygem-irb-1.0.0-109.module+el8.6.0+988+8031c193.noarch 3/22 アップグレード中 : ruby-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 4/22 アップグレード中 : rubygem-bigdecimal-1.4.1-109.module+el8.6.0+988+8031c193.x86_64 5/22 アップグレード中 : rubygem-io-console-0.4.7-109.module+el8.6.0+988+8031c193.x86_64 6/22 アップグレード中 : rubygem-psych-3.1.0-109.module+el8.6.0+988+8031c193.x86_64 7/22 アップグレード中 : rubygems-3.0.3.1-109.module+el8.6.0+988+8031c193.noarch 8/22 ダウングレード中 : rubygem-json-2.1.0-109.module+el8.6.0+988+8031c193.x86_64 9/22 アップグレード中 : rubygem-rdoc-6.1.2.1-109.module+el8.6.0+988+8031c193.noarch 10/22 アップグレード中 : ruby-devel-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 11/22 整理 : rubygem-rdoc-6.0.1.1-110.module+el8.6.0+992+fc951c18.noarch 12/22 整理 : ruby-devel-2.5.9-110.module+el8.6.0+992+fc951c18.x86_64 13/22 整理 : rubygem-json-2.1.0-110.module+el8.6.0+992+fc951c18.x86_64 14/22 廃止 : ruby-irb-2.5.9-110.module+el8.6.0+992+fc951c18.noarch 15/22 整理 : rubygem-bigdecimal-1.3.4-110.module+el8.6.0+992+fc951c18.x86_64 16/22 整理 : ruby-2.5.9-110.module+el8.6.0+992+fc951c18.x86_64 17/22 整理 : rubygem-openssl-2.1.2-110.module+el8.6.0+992+fc951c18.x86_64 18/22 整理 : rubygem-psych-3.0.2-110.module+el8.6.0+992+fc951c18.x86_64 19/22 整理 : rubygem-io-console-0.4.6-110.module+el8.6.0+992+fc951c18.x86_64 20/22 整理 : rubygems-2.7.6.3-110.module+el8.6.0+992+fc951c18.noarch 21/22 整理 : ruby-libs-2.5.9-110.module+el8.6.0+992+fc951c18.x86_64 22/22 scriptletの実行中: ruby-libs-2.5.9-110.module+el8.6.0+992+fc951c18.x86_64 22/22 検証 : rubygem-json-2.1.0-109.module+el8.6.0+988+8031c193.x86_64 1/22 検証 : rubygem-json-2.1.0-110.module+el8.6.0+992+fc951c18.x86_64 2/22 検証 : rubygem-openssl-2.1.2-109.module+el8.6.0+988+8031c193.x86_64 3/22 検証 : rubygem-openssl-2.1.2-110.module+el8.6.0+992+fc951c18.x86_64 4/22 検証 : rubygem-irb-1.0.0-109.module+el8.6.0+988+8031c193.noarch 5/22 検証 : ruby-irb-2.5.9-110.module+el8.6.0+992+fc951c18.noarch 6/22 検証 : ruby-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 7/22 検証 : ruby-2.5.9-110.module+el8.6.0+992+fc951c18.x86_64 8/22 検証 : ruby-devel-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 9/22 検証 : ruby-devel-2.5.9-110.module+el8.6.0+992+fc951c18.x86_64 10/22 検証 : ruby-libs-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 11/22 検証 : ruby-libs-2.5.9-110.module+el8.6.0+992+fc951c18.x86_64 12/22 検証 : rubygem-bigdecimal-1.4.1-109.module+el8.6.0+988+8031c193.x86_64 13/22 検証 : rubygem-bigdecimal-1.3.4-110.module+el8.6.0+992+fc951c18.x86_64 14/22 検証 : rubygem-io-console-0.4.7-109.module+el8.6.0+988+8031c193.x86_64 15/22 検証 : rubygem-io-console-0.4.6-110.module+el8.6.0+992+fc951c18.x86_64 16/22 検証 : rubygem-psych-3.1.0-109.module+el8.6.0+988+8031c193.x86_64 17/22 検証 : rubygem-psych-3.0.2-110.module+el8.6.0+992+fc951c18.x86_64 18/22 検証 : rubygem-rdoc-6.1.2.1-109.module+el8.6.0+988+8031c193.noarch 19/22 検証 : rubygem-rdoc-6.0.1.1-110.module+el8.6.0+992+fc951c18.noarch 20/22 検証 : rubygems-3.0.3.1-109.module+el8.6.0+988+8031c193.noarch 21/22 検証 : rubygems-2.7.6.3-110.module+el8.6.0+992+fc951c18.noarch 22/22 インストール済みの製品が更新されています。 アップグレード済み: ruby-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 ruby-devel-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 ruby-libs-2.6.10-109.module+el8.6.0+988+8031c193.x86_64 rubygem-bigdecimal-1.4.1-109.module+el8.6.0+988+8031c193.x86_64 rubygem-io-console-0.4.7-109.module+el8.6.0+988+8031c193.x86_64 rubygem-psych-3.1.0-109.module+el8.6.0+988+8031c193.x86_64 rubygem-rdoc-6.1.2.1-109.module+el8.6.0+988+8031c193.noarch rubygems-3.0.3.1-109.module+el8.6.0+988+8031c193.noarch ダウングレード済み: rubygem-json-2.1.0-109.module+el8.6.0+988+8031c193.x86_64 rubygem-openssl-2.1.2-109.module+el8.6.0+988+8031c193.x86_64 インストール済み: rubygem-irb-1.0.0-109.module+el8.6.0+988+8031c193.noarch 完了しました!
 Redmine 5.0.4をダウンロードし、インストールします。
# cd /usr/local/src
# wget https://www.redmine.org/releases/redmine-5.0.4.tar.gz
ハッシュ値を確認します。
# sha256sum redmine-5.0.4.tar.gz
# tar xvf redmine-5.0.4.tar.gz
# mv /usr/local/src/redmine-5.0.4 /var/www/redmine
# chown -R apache. /var/www/redmine
 古い環境から、データベースの設定ファイルとRedmineの設定ファイルをコピーします。
※旧Redmineと新Redmineが同じサーバの場合、作業不要
# pg_dump -U redmine -h 127.0.0.1 -Fc --file=redmine.sqlc
パスワード: 
# scp redmine.sqlc <リモートホストのIPアドレス>:/root

# mv /root/redmine.sqlc /var/lib/pgsql/
# chown postgres. /var/lib/pgsql/redmine.sqlc
# su - postgres
$ pg_restore -d redmine redmine.sql
※データベース「redmine」を予め作成しておく
$ psql -f redmine.sql

# su -
# cp -a /var/www/redmine_old/config/database.yml /var/www/redmine/config/
# cp -a /var/www/redmine_old/config/configuration.yml /var/www/redmine/config/
 filesディレクトリを、新しい環境にコピーします。
# cp -rp /var/www/redmine_old/files/* /var/www/redmine/files/
 使用しているプラグインがある場合、プラグインをコピーします。
 例えば、View Customizeというプラグインを使用している場合、下記のようにプラグインをコピーします。
# cp -ar /var/www/redmine_old/plugins/view_customize /var/www/redmine/plugins/
 新しいRedmineのセットアップを行います。

 新しいRedmineを展開したディレクトリで実行する必要があります。
①の場合、下記コマンドは実施しない
bundler インストール
# gem install bundler
/usr/share/ruby/yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require': \ libruby.so.2.5: cannot open shared object file: No such file or directory - /usr/lib64/gems/ruby/strscan-3.0.5/strscan.so (LoadError) from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/gems/gems/psych-3.1.0/lib/psych/scalar_scanner.rb:2:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/node.rb:4:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/gems/gems/psych-3.1.0/lib/psych/nodes.rb:2:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/gems/gems/psych-3.1.0/lib/psych.rb:19:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/ruby/yaml.rb:4:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems.rb:701:in `load_yaml' from /usr/share/rubygems/rubygems/config_file.rb:346:in `load_file' from /usr/share/rubygems/rubygems/config_file.rb:198:in `initialize' from /usr/share/rubygems/rubygems/gem_runner.rb:79:in `new' from /usr/share/rubygems/rubygems/gem_runner.rb:79:in `do_configuration' from /usr/share/rubygems/rubygems/gem_runner.rb:44:in `run' from /usr/bin/gem:21:in `<main>'

 上記「libruby.so.2.5: cannot open shared object file: No such file or directory」は「dnf module remove」や「dnf remove」で旧バージョンのRuby(2.5.9)を削除しても解決できませんでした。
 なので、下記URLを参考にして「rbenv」コマンドを使用することにしました。

 参考URL:Rubyのバージョンをチェックする方法と最新に切り替える方法

 GitHubにあるRubyのソースコードのバージョンを表示し、そこからバージョンを選んで設定する必要があります。
# rbenv install -l
bash: rbenv: コマンドが見つかりませんでした... コマンド rbenv' を提供するためにパッケージ 'rbenv' をインストールしますか? [N/y] y * キューで待機中... * パッケージの一覧をロード中。... 以下のパッケージはインストールされるべきものです: gdbm-devel-1:1.18-2.el8.x86_64 Development libraries and header files for the gdbm library libffi-devel-3.1-23.el8.x86_64 Development files for libffi llvm-14.0.6-1.module+el8.7.0+1080+d88dc670.x86_64 The Low Level Virtual Machine llvm-devel-14.0.6-1.module+el8.7.0+1080+d88dc670.x86_64 Libraries and header files for LLVM llvm-static-14.0.6-1.module+el8.7.0+1080+d88dc670.x86_64 LLVM static libraries llvm-test-14.0.6-1.module+el8.7.0+1080+d88dc670.x86_64 LLVM regression tests ncurses-c++-libs-6.1-9.20180224.el8.x86_64 Ncurses C++ bindings ncurses-devel-6.1-9.20180224.el8.x86_64 Development files for the ncurses library rbenv-1.2.0-1.el8.x86_64 Manage your app's Ruby environment readline-devel-7.0-10.el8.x86_64 Files needed to develop programs which use the readline library ruby-build-20221004-1.el8.x86_64 Compile and install Ruby ruby-build-rbenv-20221004-1.el8.x86_64 rbenv plugin to compile and install Ruby rubygem-rake-12.3.3-109.module+el8.6.0+988+8031c193.noarch Ruby based make-like utility rust-1.62.1-1.module+el8.7.0+1079+7c7e1744.x86_64 The Rust Programming Language rust-std-static-1.62.1-1.module+el8.7.0+1079+7c7e1744.x86_64 Standard library for Rust 変更したまま継続しますか? [N/y] y * キューで待機中... * 認証を待ち受け中... * キューで待機中... * パッケージをダウンロード中... * データを要求中... * 変更をテスト中... * パッケージのインストール中... 2.6.10 2.7.6 3.0.4 3.1.2 jruby-9.3.8.0 mruby-3.1.0 picoruby-3.0.0 rbx-5.0 truffleruby-22.2.0 truffleruby+graalvm-22.2.0 Only latest stable releases for each Ruby implementation are shown. Use 'rbenv install --list-all / -L' to show all local versions.
 下記コマンドでRubyのバージョンを確認します。
# rbenv versions
* system
 「system」と表示されていますので、dnfでインストールしたバージョン(ruby 2.6.10p210 (2022-04-12 revision 67958) [x86_64-linux])を意味しているのでしょう。
 下記コマンドで、2.6.10をインストールします。
# rbenv install 2.6.10
To follow progress, use 'tail -f /tmp/ruby-build.20230110074300.48755.log' or pass --verbose
Downloading ruby-2.6.10.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.10.tar.bz2
Installing ruby-2.6.10...
Installed ruby-2.6.10 to /root/.rbenv/versions/2.6.10 ← あとでこれが問題となる。


NOTE: to activate this Ruby version as the new default, run: rbenv global 2.6.10
 Ruby 2.6が「/root/.rbenv/versions/2.6.10」にインストールされました。

 rbenvでバージョンを確認します。
# rbenv versions
* system
  2.6.10
 2.6.10が表示されました。
 使用するバージョンを切り替えます。
# rbenv global 2.6.10
# rbenv versions
  system
* 2.6.10 (set by /root/.rbenv/version)
 切り替わりました。

 再度、bundlerをインストールします。
# cd /var/www/redmine

bundler インストール
# gem install bundler
/usr/share/ruby/yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require': \ libruby.so.2.5: cannot open shared object file: No such file or directory - /usr/lib64/gems/ruby/strscan-3.0.5/strscan.so (LoadError) from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/gems/gems/psych-3.1.0/lib/psych/scalar_scanner.rb:2:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/gems/gems/psych-3.1.0/lib/psych/nodes/node.rb:4:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/gems/gems/psych-3.1.0/lib/psych/nodes.rb:2:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/gems/gems/psych-3.1.0/lib/psych.rb:19:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/ruby/yaml.rb:4:in `<top (required)>' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in `require' from /usr/share/rubygems/rubygems.rb:701:in `load_yaml' from /usr/share/rubygems/rubygems/config_file.rb:346:in `load_file' from /usr/share/rubygems/rubygems/config_file.rb:198:in `initialize' from /usr/share/rubygems/rubygems/gem_runner.rb:79:in `new' from /usr/share/rubygems/rubygems/gem_runner.rb:79:in `do_configuration' from /usr/share/rubygems/rubygems/gem_runner.rb:44:in `run' from /usr/bin/gem:21:in `<main>'
 状況は変わりませんでした。

 参考URL:PDF全文検索サーバー構築、再び。honyomiをリモートサーバー上で稼働させ、外でも読書できるようにするのよ。

 rbenvコマンドでインストールしたRubyのパスが通っていないようなので、パスを設定します。
# echo 'export PATH="$HOME/.rbenv/versions/2.6.10/bin/:$PATH"' >> ~/.bash_profile
# source ~/.bash_profile
 再度、bundlerをインストールします。
bundler インストール
# gem install bundler
Fetching bundler-2.4.3.gem
Successfully installed bundler-2.4.3
Parsing documentation for bundler-2.4.3
Installing ri documentation for bundler-2.4.3
Done installing documentation for bundler after 0 seconds
1 gem installed
 今度は正常に完了しました。
Redmineで使用するGemをインストール
# bundle install --without development test mysql sqlite
Fetching gem metadata from https://rubygems.org/......... Resolving dependencies... Fetching rake 13.0.6 Installing rake 13.0.6  :  : Fetching net-imap 0.2.3 Installing net-imap 0.2.3 Bundle complete! 42 Gemfile dependencies, 73 gems now installed. Gems in the groups 'development', 'test', 'mysql' and 'sqlite' were not installed. Use `bundle info [gemname]` to see where a bundled gem is installed. Post-install message from html-pipeline: ------------------------------------------------- Thank you for installing html-pipeline! You must bundle Filter gem dependencies. See html-pipeline README.md for more details. https://github.com/jch/html-pipeline#dependencies ------------------------------------------------- Post-install message from rubyzip: RubyZip 3.0 is coming! ********************** The public API of some Rubyzip classes has been modernized to use named parameters for optional arguments. Please check your usage of the following classes: * `Zip::File` * `Zip::Entry` * `Zip::InputStream` * `Zip::OutputStream` Please ensure that your Gemfiles and .gemspecs are suitably restrictive to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0). See https://github.com/rubyzip/rubyzip for details. The Changelog also lists other enhancements and bugfixes that have been implemented since version 2.3.0.
 正常に完了しました。

 後は、たんたんと作業を進めることが出来るはずです。
秘密鍵の生成
# bundle exec rake generate_secret_token
 正常に完了しました。
テーブル生成
# bundle exec rake db:migrate RAILS_ENV=production
 正常に完了しました。
Passengerインストール
# gem install passenger
Fetching passenger-6.0.16.gem
Building native extensions. This could take a while...
Successfully installed passenger-6.0.16
Parsing documentation for passenger-6.0.16
Installing ri documentation for passenger-6.0.16
Done installing documentation for passenger after 53 seconds
1 gem installed
 正常に完了しました。
Apache httpd用モジュールインストール
# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v6.0.16. This installer will guide you through the entire installation process. It shouldn't take more than 3 minutes in total. Here's what you can expect from the installation process: 1. The Apache 2 module will be installed for you. 2. You'll learn how to configure Apache. 3. You'll learn how to deploy a Ruby on Rails application. Don't worry if anything goes wrong. This installer will advise you on how to solve any problems. Press Enter to continue, or Ctrl-C to abort. -------------------------------------------- Which languages are you interested in? Use to select. If the menu doesn't display correctly, press '!' ‣ ⬢ Ruby ⬡ Python ⬡ Node.js ⬡ Meteor --------------------------------------------  :  : -------------------------------------------- Almost there! Please edit your Apache configuration file, and add these lines: LoadModule passenger_module /root/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/passenger-6.0.16/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /root/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/passenger-6.0.16 PassengerDefaultRuby /root/.rbenv/versions/2.6.10/bin/ruby </IfModule> After you restart Apache, you are ready to deploy any number of web applications on Apache, with a minimum amount of configuration! Press ENTER when you are done editing. -------------------------------------------- Validating installation... * Checking whether this Passenger install is in PATH... (!) Please add /root/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/passenger-6.0.16/bin to PATH. Otherwise you will get "command not found" errors upon running any Passenger commands. Learn more at about PATH at: https://www.phusionpassenger.com/library/indepth/environment_variables.html#the-path-environment-variable * Checking whether there are no other Passenger installations... ✓ * Checking whether Apache is installed... ✓ * Checking whether the Passenger module is correctly configured in Apache... ✗ Your Apache installation might be broken You are about to validate Phusion Passenger(R) against the following Apache installation: apxs2 : /usr/bin/apxs Executable: /usr/sbin/httpd Version : 2.4.37 However, this Apache installation appears to be broken, so this program cannot continue. To find out why this program thinks the above Apache installation is broken, run: export ORIG_PATH="$PATH" sudo -s -E export PATH="$ORIG_PATH" /root/.rbenv/versions/2.6.10/bin/ruby /root/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/passenger-6.0.16/bin/passenger-config --detect-apache2 Detected 1 error(s), 1 warning(s). Please solve the above issues, then press ENTER to continue. -------------------------------------------- Deploying a web application To learn how to deploy a web app on Passenger, please follow the deployment guide: https://www.phusionpassenger.com/library/deploy/apache/deploy/ Enjoy Phusion Passenger, a product of Phusion® (www.phusion.nl) :-) https://www.phusionpassenger.com Passenger® is a registered trademark of Phusion Holding B.V.
 正常に完了しました。
# vi /etc/httpd/conf.d/redmine.conf
※rbenvを利用しているため、passengerのフォルダを変更
#LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.16/buildout/apache2/mod_passenger.so
#PassengerRoot /usr/local/share/gems/gems/passenger-6.0.16
#PassengerDefaultRuby /usr/bin/ruby
 ↓
LoadModule passenger_module /root/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/passenger-6.0.16/buildout/apache2/mod_passenger.so
PassengerRoot /root/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/passenger-6.0.16
PassengerDefaultRuby /root/.rbenv/versions/2.6.10/bin/ruby

# ln -s /var/www/redmine/public /var/www/html/redmine

# chown -R apache. /var/www/redmine
# systemctl restart httpd
 ブラウザで接続するとエラーが表示されました。
We're sorry, but something went wrong.
The issue has been logged for investigation. Please try again later.
 ログ(/var/log/httpd/error_log)を確認します。

App 24398 output: Error: Unable to execute command '/root/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/passenger-6.0.16/buildout/support-binaries/PassengerAgent spawn-env-setupper /tmp/passenger.spawn.XXXXoLoat8 --after': Permission denied (errno=13)
[ E 2023-01-10 10:17:09.3189 24043/Tt age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/redmine: Unable to execute command '/root/.rbenv/versions/2.6.10/lib/ruby/gems/2.6.0/gems/passenger-6.0.16/buildout/support-binaries/PassengerAgent spawn-env-setupper /tmp/passenger.spawn.XXXXoLoat8 --after': Permission denied (errno=13)
Error ID: 9b4814b8
Error details saved to: /tmp/passenger-error-VM90Fb.html

[ E 2023-01-10 10:17:09.3218 24043/Tc age/Cor/Con/CheckoutSession.cpp:283 ]: [Client 3-1] Cannot checkout session because a spawning error occurred. The identifier of the error is 9b4814b8.
Please see earlier logs for details about the error.


 参考URL:PDF全文検索サーバー構築、再び。honyomiをリモートサーバー上で稼働させ、外でも読書できるようにするのよ。

 /rootを751、/root/.rbenvを755に変更します。
# ls -ld /root
dr-xr-x---. 11 root root 4096  1月 10 08:16 /root
# ls -ld /root/.rbenv
drwxr-xr-x 4 root root 50  1月 10 07:52 /root/.rbenv

※/root/.rbenvは変更不要でした。

# chmod 751 /root
# ls -ld /root
drwxr-x--x. 11 root root 4096  1月 10 08:16 /root
 これで、ブラウザで正常にアクセスできるようになりました。
 これで良いかどうかは・・・微妙。
 passengerが/root以下にインストールされてしまっているのが、そもそもの原因か。
 このまま利用するのであれば、アクセス制御を設定するべきかもしれない。
 passengerを/usr/localや/opt以下にインストールし、apache や www といったユーザ権限で実行できるようにすることがお薦めかも。

●Redmineを5.0.1から5.0.4へアップデート(その3):Ruby 2.7.6を選択

 参考URL:rbenvとruby環境の構築手順
 参考URL:rbenv+ruby-buildをインストールする手順 (CentOS/RedHat)
 参考URL:rbenvをインストールする-Ruby
 参考URL:rbenvでディレクトリ毎にRubyのバージョンを指定する

 上記の「passengerを/usr/localや/opt以下にインストールし、apache や www といったユーザ権限で実行できるようにすることがお薦めかも。」ということで、rbenvのインストールディレクトリを変更することにします。

 rbenvを/optにインストールします。
 GitHubからrbenvを/opt/rbenvにダウンロード (clone) します。
# cd /opt
# git clone https://github.com/rbenv/rbenv.git ./rbenv
Cloning into 'rbenv'...
remote: Enumerating objects: 3154, done.
remote: Counting objects: 100% (304/304), done.
remote: Compressing objects: 100% (170/170), done.
remote: Total 3154 (delta 172), reused 232 (delta 122), pack-reused 2850
Receiving objects: 100% (3154/3154), 634.20 KiB | 1.41 MiB/s, done.
Resolving deltas: 100% (1962/1962), done.
 /etc/profileにrbenvへパスを通す設定と初期化を行うための行を追記します。
# echo 'export RBENV_ROOT="/opt/rbenv"' >> /etc/profile
# echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile
# echo 'eval "$(rbenv init -)"' >> /etc/profile
 ruby-buildは、rbenv installコマンドを提供するrbenvのプラグインです。
 ruby-buildプラグインをrbenvをインストールしたディレクトリ内のpluginsフォルダにインストールします。
# mkdir /opt/rbenv/plugins
# cd /opt/rbenv/plugins
# git clone https://github.com/rbenv/ruby-build.git ./ruby-build
Cloning into 'ruby-build'...
remote: Enumerating objects: 13568, done.
remote: Counting objects: 100% (2255/2255), done.
remote: Compressing objects: 100% (341/341), done.
remote: Total 13568 (delta 2018), reused 2031 (delta 1890), pack-reused 11313
Receiving objects: 100% (13568/13568), 2.71 MiB | 2.43 MiB/s, done.
Resolving deltas: 100% (9268/9268), done.
 これでrbenv installが使えるようになりました
 インストールできるrubyのバージョンを確認します。
# rbenv install -l
2.6.10
2.7.6
3.0.4
3.1.2
jruby-9.3.8.0
mruby-3.1.0
picoruby-3.0.0
rbx-5.0
truffleruby-22.2.0
truffleruby+graalvm-22.2.0

Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.
 今回は2.7.6を選択します。
# rbenv install 2.7.6
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.bz2
Installing ruby-2.7.6...

WARNING: ruby-2.7.6 is nearing its end of life.
It only receives critical security updates, no bug fixes.

Installed ruby-2.7.6 to /opt/rbenv/versions/2.7.6


NOTE: to activate this Ruby version as the new default, run: rbenv global 2.7.6

# rbenv global 2.7.6
# rbenv versions
  system
* 2.7.6 (set by /opt/rbenv/version)
 それでは、ここからRedmineを利用できるように設定していきます。
# cd /usr/local/src
# wget https://www.redmine.org/releases/redmine-5.0.4.tar.gz
ハッシュ値を確認
# sha256sum redmine-5.0.4.tar.gz
# tar zxf redmine-5.0.4.tar.gz
# mv /usr/local/src/redmine-5.0.4 /var/www/redmine-5.0.4

# cd /var/www/redmine-5.0.4/
# cp -p /var/www/redmine_old/config/configuration.yml config/
# cp -p /var/www/redmine_old/config/database.yml config/

filesディレクトリを、新しい環境にコピー
# cp -rp /var/www/redmine_old/files/* files/

使用しているプラグインがある場合、プラグインをコピー
例えば、View Customizeというプラグインを使用している場合、下記のようにプラグインをコピー
# cp -ar /var/www/redmine_old/plugins/view_customize /var/www/redmine-5.0.4/plugins/

bundler インストール
# gem install bundler
Fetching bundler-2.4.5.gem
Successfully installed bundler-2.4.5
Parsing documentation for bundler-2.4.5
Installing ri documentation for bundler-2.4.5
Done installing documentation for bundler after 0 seconds
1 gem installed
Redmineで使用するGemをインストール
# bundle install --without development test mysql sqlite
Fetching gem metadata from https://rubygems.org/......... Resolving dependencies... Fetching rake 13.0.6 Installing rake 13.0.6 Fetching zeitwerk 2.6.6 Fetching concurrent-ruby 1.1.10 Fetching builder 3.2.4 Fetching minitest 5.17.0 Installing builder 3.2.4 Installing zeitwerk 2.6.6 Fetching erubi 1.12.0 Installing minitest 5.17.0 Fetching racc 1.6.2 Installing erubi 1.12.0 Installing concurrent-ruby 1.1.10 Installing racc 1.6.2 with native extensions Fetching crass 1.0.6 Fetching rack 2.2.6.2 Installing crass 1.0.6 Installing rack 2.2.6.2 Fetching nio4r 2.5.8 Installing nio4r 2.5.8 with native extensions Fetching websocket-extensions 0.1.5 Installing websocket-extensions 0.1.5 Fetching marcel 1.0.2 Fetching mini_mime 1.1.2 Installing marcel 1.0.2 Installing mini_mime 1.1.2 Fetching method_source 1.0.0 Fetching thor 1.2.1 Installing method_source 1.0.0 Installing thor 1.2.1 Fetching public_suffix 5.0.1 Using bundler 2.4.5 Fetching chunky_png 1.4.0 Installing public_suffix 5.0.1 Fetching commonmarker 0.23.6 Installing chunky_png 1.4.0 Installing commonmarker 0.23.6 with native extensions Fetching csv 3.2.6 Installing csv 3.2.6 Fetching digest 3.1.1 Installing digest 3.1.1 with native extensions Fetching htmlentities 4.3.4 Installing htmlentities 4.3.4 Fetching mini_magick 4.11.0 Installing mini_magick 4.11.0 Fetching timeout 0.3.1 Installing timeout 0.3.1 Fetching strscan 3.0.5 Installing strscan 3.0.5 with native extensions Fetching net-ldap 0.17.1 Installing net-ldap 0.17.1 Fetching pg 1.2.3 Installing pg 1.2.3 with native extensions Fetching rbpdf-font 1.19.1 Fetching redcarpet 3.5.1 Installing redcarpet 3.5.1 with native extensions Installing rbpdf-font 1.19.1 Fetching rotp 6.2.2 Installing rotp 6.2.2 Fetching rouge 3.28.0 Installing rouge 3.28.0 Fetching rqrcode_core 1.2.0 Installing rqrcode_core 1.2.0 Fetching rubyzip 2.3.2 Installing rubyzip 2.3.2 Fetching rack-test 2.0.2 Installing rack-test 2.0.2 Fetching request_store 1.5.1 Installing request_store 1.5.1 Fetching i18n 1.10.0 Installing i18n 1.10.0 Fetching tzinfo 2.0.5 Installing tzinfo 2.0.5 Fetching sprockets 4.2.0 Installing sprockets 4.2.0 Fetching websocket-driver 0.7.5 Installing websocket-driver 0.7.5 with native extensions Fetching mail 2.7.1 Installing mail 2.7.1 Fetching addressable 2.8.1 Installing addressable 2.8.1 Fetching nokogiri 1.13.10 (x86_64-linux) Installing nokogiri 1.13.10 (x86_64-linux) Fetching net-protocol 0.2.1 Installing net-protocol 0.2.1 Fetching rbpdf 1.20.1 Installing rbpdf 1.20.1 Fetching rqrcode 2.1.2 Installing rqrcode 2.1.2 Fetching activesupport 6.1.7 Installing activesupport 6.1.7 Fetching css_parser 1.14.0 Installing css_parser 1.14.0 Fetching loofah 2.19.1 Installing loofah 2.19.1 Fetching sanitize 6.0.0 Installing sanitize 6.0.0 Fetching net-pop 0.1.2 Installing net-pop 0.1.2 Fetching net-smtp 0.3.3 Installing net-smtp 0.3.3 Fetching rails-dom-testing 2.0.3 Installing rails-dom-testing 2.0.3 Fetching globalid 1.0.1 Installing globalid 1.0.1 Fetching activemodel 6.1.7 Installing activemodel 6.1.7 Fetching html-pipeline 2.13.2 Installing html-pipeline 2.13.2 Fetching roadie 5.1.0 Installing roadie 5.1.0 Fetching rails-html-sanitizer 1.5.0 Installing rails-html-sanitizer 1.5.0 Fetching activejob 6.1.7 Installing activejob 6.1.7 Fetching activerecord 6.1.7 Installing activerecord 6.1.7 Fetching deckar01-task_list 2.3.2 Installing deckar01-task_list 2.3.2 Fetching actionview 6.1.7 Installing actionview 6.1.7 Fetching actionpack 6.1.7 Installing actionpack 6.1.7 Fetching activestorage 6.1.7 Fetching actionmailer 6.1.7 Fetching railties 6.1.7 Installing actionmailer 6.1.7 Installing activestorage 6.1.7 Fetching sprockets-rails 3.4.2 Installing sprockets-rails 3.4.2 Installing railties 6.1.7 Fetching actioncable 6.1.7 Installing actioncable 6.1.7 Fetching actionmailbox 6.1.7 Installing actionmailbox 6.1.7 Fetching actiontext 6.1.7 Installing actiontext 6.1.7 Fetching rails 6.1.7 Fetching actionpack-xml_parser 2.0.1 Fetching roadie-rails 3.0.0 Installing rails 6.1.7 Installing roadie-rails 3.0.0 Installing actionpack-xml_parser 2.0.1 Fetching net-imap 0.2.3 Installing net-imap 0.2.3 Bundle complete! 42 Gemfile dependencies, 73 gems now installed. Gems in the groups 'development', 'test', 'mysql' and 'sqlite' were not installed. Use `bundle info [gemname]` to see where a bundled gem is installed. Post-install message from html-pipeline: ------------------------------------------------- Thank you for installing html-pipeline! You must bundle Filter gem dependencies. See html-pipeline README.md for more details. https://github.com/jch/html-pipeline#dependencies ------------------------------------------------- Post-install message from rubyzip: RubyZip 3.0 is coming! ********************** The public API of some Rubyzip classes has been modernized to use named parameters for optional arguments. Please check your usage of the following classes: * `Zip::File` * `Zip::Entry` * `Zip::InputStream` * `Zip::OutputStream` Please ensure that your Gemfiles and .gemspecs are suitably restrictive to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0). See https://github.com/rubyzip/rubyzip for details. The Changelog also lists other enhancements and bugfixes that have been implemented since version 2.3.0.
秘密鍵の生成 # bundle exec rake generate_secret_token テーブル生成 # bundle exec rake db:migrate RAILS_ENV=production Passengerインストール # gem install passenger Fetching passenger-6.0.16.gem Building native extensions. This could take a while... Successfully installed passenger-6.0.16 Parsing documentation for passenger-6.0.16 Installing ri documentation for passenger-6.0.16 Done installing documentation for passenger after 28 seconds 1 gem installed Apache httpd用モジュールインストール # passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v6.0.16. This installer will guide you through the entire installation process. It shouldn't take more than 3 minutes in total. Here's what you can expect from the installation process: 1. The Apache 2 module will be installed for you. 2. You'll learn how to configure Apache. 3. You'll learn how to deploy a Ruby on Rails application. Don't worry if anything goes wrong. This installer will advise you on how to solve any problems. Press Enter to continue, or Ctrl-C to abort. -------------------------------------------- Which languages are you interested in? Use <space> to select. If the menu doesn't display correctly, press '!' ‣ ⬢ Ruby ⬡ Python ⬡ Node.js ⬡ Meteor -------------------------------------------- Checking for required software... * Checking for C compiler... Found: yes Location: /usr/bin/cc * Checking for C++ compiler... Found: yes Location: /usr/bin/c++ * Checking for Curl development headers with SSL support... Found: yes curl-config location: /usr/bin/curl-config Header location: somewhere, not sure where Version: libcurl 7.61.1 Usable: yes Supports SSL: yes  :  :  : checking for alloca.h... yes checking for ruby/version.h... yes checking for ruby/io.h... yes checking for ruby/thread.h... yes checking for ruby_version... no checking for rb_thread_io_blocking_region() in ruby/io.h... yes checking for rb_thread_call_without_gvl() in ruby/thread.h... yes creating Makefile cd 'buildout/ruby/ruby-2.7.6-x86_64-linux/' && make compiling /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/passenger-6.0.16/src/ruby_native_extension/passenger_native_support.c linking shared-object passenger_native_support.so -------------------------------------------- Almost there! Please edit your Apache configuration file, and add these lines: LoadModule passenger_module /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/passenger-6.0.16/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/passenger-6.0.16 PassengerDefaultRuby /opt/rbenv/versions/2.7.6/bin/ruby </IfModule> After you restart Apache, you are ready to deploy any number of web applications on Apache, with a minimum amount of configuration! Press ENTER when you are done editing. -------------------------------------------- Validating installation... * Checking whether this Passenger install is in PATH... ✓ * Checking whether there are no other Passenger installations... (!) You are currently validating against Phusion Passenger(R) 6.0.16, located in: /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/passenger-6.0.16/bin/passenger Besides this Passenger installation, the following other Passenger installations have also been detected: /opt/rbenv/shims/passenger /usr/local/bin/passenger Please uninstall these other Passenger installations to avoid confusion or conflicts. * Checking whether Apache is installed... ✓ * Checking whether the Passenger module is correctly configured in Apache... \ [Mon Jan 23 14:10:45.163573 2023] [so:warn] [pid 141788:tid 140066268868032] AH01574: module passenger_module is already loaded, skipping ✗ You have 2 'LoadModule passenger_module' directives in your Apache configuration files. However, you are only supposed to have one such directive. Please fix this by removing all 'LoadModule passenger_module' directives besides the one for Passenger version 6.0.16. The directives were found in these files: /etc/httpd/conf.d/redmine2.conf /etc/httpd/conf.d/redmine.conf Note: 'LoadModule passenger_module' may be placed inside the global context only (so not within a VirtualHost). Detected 1 error(s), 1 warning(s). Please solve the above issues, then press ENTER to continue. -------------------------------------------- Deploying a web application To learn how to deploy a web app on Passenger, please follow the deployment guide: https://www.phusionpassenger.com/library/deploy/apache/deploy/ Enjoy Phusion Passenger, a product of Phusion® (www.phusion.nl) :-) https://www.phusionpassenger.com Passenger® is a registered trademark of Phusion Holding B.V.
 Webサーバに関する設定をします。
Redmine新バージョン用設定ファイルを用意
# cp -p /etc/httpd/conf.d/redmine.conf /etc/httpd/conf.d/redmine-5.0.4.conf

Redmine旧バージョンの設定ファイルを退避
# mv /etc/httpd/conf.d/redmine.conf /etc/httpd/conf.d/redmine.conf_

Redmine新バージョン用設定ファイルを編集
# vi /etc/httpd/conf.d/redmine-5.0.4.conf
※別途設定ファイルがある場合、該当ファイル名を読み込まれないよう一時的に退避するなどの設定変更が必要

旧バージョンを指定していたフォルダを新バージョンに指定するよう変更
<Directory "/var/www/redmine/public">
 ↓
<Directory "/var/www/redmine-5.0.4/public">

passengerの指定に関する変更
#LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
#PassengerRoot /usr/local/share/gems/gems/passenger-6.0.14
#PassengerDefaultRuby /usr/bin/ruby
 ↓
LoadModule passenger_module /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/passenger-6.0.16/buildout/apache2/mod_passenger.so
PassengerRoot /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/passenger-6.0.16
PassengerDefaultRuby /opt/rbenv/versions/2.7.6/bin/ruby

旧バージョンのRedmineと同じURLでアクセスさせたいため、下記行は変更しない
RailsBaseURI /redmine

旧バージョンのソフトリンクを削除
# rm /var/www/html/redmine

新バージョンへソフトリンクを設定
# ln -s /var/www/redmine-5.0.4/public /var/www/html/redmine

# chown -R apache. /var/www/redmine-5.0.4
# systemctl restart httpd
 以上で、旧バージョンで使用していたURLで新バージョンのRedmineにアクセスできるようになります。

 旧Redmineバージョン環境に戻すには

 Rubyのバージョンをアップデート後、旧環境を利用するには再度イチから環境を設定する必要があります。
 データベースの設定は完了しているものとします。

 旧バージョンのRedmineがインストールされているディレクトリに移動します。
# cd /var/www/redmine

bundler インストール
# gem install bundler

Redmineで使用するGemをインストール
# bundle install --without development test mysql sqlite

秘密鍵の生成
# bundle exec rake generate_secret_token

テーブル生成
# bundle exec rake db:migrate RAILS_ENV=production

Passengerインストール
# gem install passenger

Apache httpd用モジュールインストール
# passenger-install-apache2-module

Redmine旧バージョン用設定ファイルを用意
# cp -p /etc/httpd/conf.d/redmine.conf_ /etc/httpd/conf.d/redmine.conf

Redmine旧バージョンの設定ファイルを退避
# mv /etc/httpd/conf.d/redmine.conf /etc/httpd/conf.d/redmine.conf_

Redmine新バージョン用設定ファイルを編集
# vi /etc/httpd/conf.d/redmine-5.0.4.conf
#LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
#PassengerRoot /usr/local/share/gems/gems/passenger-6.0.14
#PassengerDefaultRuby /usr/bin/ruby
 ↓
LoadModule passenger_module /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/passenger-6.0.16/buildout/apache2/mod_passenger.so
PassengerRoot /opt/rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/passenger-6.0.16
PassengerDefaultRuby /opt/rbenv/versions/2.7.6/bin/ruby

RailsBaseURI /redmine
 ↓
RailsBaseURI /redmine_old

旧バージョンを指定していたフォルダを新バージョンに指定するよう変更

# ln -s /var/www/redmine/public /var/www/html/redmine_old

# systemctl restart httpd
 これにより、Redmine旧バージョン(5.0.1)がRubyバージョン2.7.6で動作します。

 環境を確認するにはrbenv-doctorを利用します。
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: multiple
  You seem to have multiple rbenv installs in the following locations.
  Please pick just one installation and remove the others.
  
  /opt/rbenv/bin/rbenv
  /usr/bin/rbenv

Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /opt/rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20221225-9-g697bcff)
Counting installed Ruby versions: 1 versions
Auditing installed plugins: OK