見出し画像

Amazon EC2 (Ubuntu 20.04) に Redmine 4.2 をインストール

GW 最終日。
昼から妻が出かけて僕の時間ができたので、うまくいかなかった Ubuntu の Redmine 構築をリベンジしました。Puma を学ぶ機会になったので、備忘のため投稿します。

EC2 インスタンス起動

まず、仮想マシンを起動します。
SSH は使わず、セッションマネージャーを利用してアクセスします。

名前とタグ

EC2 コンソールから、[インスタンスを起動] ボタンをクリック。
名前とタグは「my-redmine-ubuntu20.04」にしました。

マシンイメージ

AMI は 手順通り Ubuntu 20.04 LTS にしました。

インスタンスタイプ

過去に passenger でメモリ不足のエラーが表示されてインストールできなかった記憶があるため、インスタンスファミリーは t3.small にしました。

キーペア (ログイン)

男らしくキーペアなし。

ネットワーク設定

セッションマネージャーを使うため、パブリックサブネットを指定して、パブリック IP アドレスを付与しました。セキュリティグループは 80 ポートのみ開放。

ストレージ

gp2 から gp3 に変更しました。

高度な詳細

セッションマネージャーを利用するため、IAM インスタンスプロファイル (IAM ロール) は AmazonEC2RoleforSSM をアタッチしました。
中断あたりにあるクレジット仕様はスタンダードにしました。

また、公式ドキュメントの記載通り、ユーザーデータに以下スクリプトを流しました。

#!/bin/bash
systemctl start snap.amazon-ssm-agent.amazon-ssm-agent.service

ステータスチェック OK を待たずに、2 分程度でセッションマネージャー経由でサーバーにログインできました。

$ sudo -i
root@ip-172-29-0-207:~# su - ubuntu
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ip-172-29-0-207:~$

Redmine 4.2 はインストールできませんでした

こちらの手順を参考にインストールを進めましたが、Ruby 2.4 〜 2.7 が OpenSSL のエラーでインストールできなかったです。
そのため、Redline 5.0 をインストールしました。(4.2 は参考情報として記載していますが、スキップしてください。)

ロケールの設定

ubuntu@ip-172-29-0-207:~$ sudo locale-gen ja_JP.UTF-8
Generating locales (this might take a while)...
ja_JP.UTF-8... done
Generation complete.
ubuntu@ip-172-29-0-207:~$ locale -a
C
C.utf8
POSIX
en_US.utf8
ja_JP.utf8
ubuntu@ip-172-29-0-207:~$

UTC+9 に変更

ubuntu@ip-172-29-0-166:~$ sudo timedatectl set-timezone Asia/Tokyo
ubuntu@ip-172-29-0-166:~$ date
Sat May  7 11:38:58 JST 2022
ubuntu@ip-172-29-0-166:~$

パッケージ更新

ubuntu@ip-172-29-0-207:~$ sudo apt update
Get:1 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease [270 kB]

(中略)

Reading state information... Done
18 packages can be upgraded. Run 'apt list --upgradable' to see them.
ubuntu@ip-172-29-0-207:~$

Ruby と Passenger 関連のツール類をインストール

ubuntu@ip-172-29-0-207:~$ sudo apt install -y build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev libffi-dev

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

(中略)

途中で BIOS みたいな画面が出てきました。再起動するサービスを選択するようです。ENTER キーを押下して進めました。

(中略)

systemctl restart user@0.service
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
ubuntu@ip-172-29-0-207:~$

PostgreSQLとヘッダファイルのインストール

ubuntu@ip-172-29-0-207:~$ sudo apt install -y postgresql libpq-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

(中略)

またサービスの再起動画面が表示されました。

今回は [Space] キーを押下して二つともリスタートしました。

Apache などインストール

ubuntu@ip-172-29-0-207 :~$ sudo apt install -y apache2 apache2-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:

(中略)

No VM guests are running outdated hypervisor (qemu) binaries on this host.
ubuntu@ip-172-29-0-207:~$

ブラウザからアクセス

ブラウザからグローバル IP アドレスでアクセスすると、Apache2 のデフォルトページが表示されました。

日本語フォントなどインストール

ubuntu@ip-172-29-0-207:~$ sudo apt install -y imagemagick fonts-takao-pgothic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:

(中略)

No VM guests are running outdated hypervisor (qemu) binaries on this host.
ubuntu@ip-172-29-0-207:~$

そのほかのツール (SVN, Git) をインストール

ubuntu@ip-172-29-0-207:~$ sudo apt install -y subversion git
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libserf-1-1 libsvn1 libutf8proc2
Suggested packages:

(中略)

No VM guests are running outdated hypervisor (qemu) binaries on this host.
ubuntu@ip-172-29-0-207:~$

Ruby インストール

Ruby のインストールは手順通り進めると OpenSSL 関係のエラーが表示されてインストールに失敗しました。
そこで、sudo apt install ruby を実行したのですが、ruby 3.0.2 がインストールされまして、Redline は 2.4 から 2.7 しか対応していないので、バージョンを下げてインストールする必要がありました。
rbenv も使いましたが、これも OpenSSL まわりでエラーが出ました。

手順通りに進めた場合

まず、手順通りに進めてみました。wget で 2.7 を取得して

ubuntu@ip-172-29-0-169:~$ wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.gz
--2022-05-05 22:43:14--  https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.gz
Resolving cache.ruby-lang.org (cache.ruby-lang.org)... 151.101.229.178, 2a04:4e42:36::434
Connecting to cache.ruby-lang.org (cache.ruby-lang.org)|151.101.229.178|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16919639 (16M) [application/x-tar]
Saving to: ‘ruby-2.7.6.tar.gz’
ruby-2.7.6.tar.gz                   100%[===================================================================>]  16.14M  --.-KB/s    in 0.09s
2022-05-05 22:43:15 (170 MB/s) - ‘ruby-2.7.6.tar.gz’ saved [16919639/16919639]
ubuntu@ip-172-29-0-169:~$

手順通り解凍して configure し

ubuntu@ip-172-29-0-169:~$ tar xf ruby-2.7.6.tar.gz
ubuntu@ip-172-29-0-169:~$ cd ruby-2.7.6/
ubuntu@ip-172-29-0-169:~/ruby-2.7.6$ ./configure --disable-install-doc
checking for ruby... false
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for gcc... gcc

(中略)

config.status: creating ruby-2.7.pc
---
Configuration summary for ruby version 2.7.6

   * Installation prefix: /usr/local
   * exec prefix:         ${prefix}
   * arch:                x86_64-linux
   * site arch:           ${arch}
   * RUBY_BASE_NAME:      ruby
   * ruby lib prefix:     ${libdir}/${RUBY_BASE_NAME}
   * site libraries path: ${rubylibprefix}/${sitearch}
   * vendor path:         ${rubylibprefix}/vendor_ruby
   * target OS:           linux
   * compiler:            gcc
   * with pthread:        yes
   * with coroutine:      amd64
   * enable shared libs:  no
   * dynamic library ext: so
   * CFLAGS:              ${optflags} ${debugflags} ${warnflags}
   * LDFLAGS:             -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic
   * DLDFLAGS:            -Wl,--compress-debug-sections=zlib
   * optflags:            -O3
   * debugflags:          -ggdb3
   * warnflags:           -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int \
                          -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn \
                          -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers \
                          -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign \
                          -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format \
                          -Wsuggest-attribute=noreturn -Wunused-variable
   * strip command:       strip -S -x
   * install doc:         no
   * JIT support:         yes
   * man page type:       doc

---
ubuntu@ip-172-29-0-169:~/ruby-2.7.6$

make して、

ubuntu@ip-172-29-0-169:~/ruby-2.7.6$ make
BASERUBY = echo executable host ruby is required.  use --with-baseruby option.; false
CC = gcc
LD = ld
LDSHARED = gcc -shared
CFLAGS = -g -O2
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -fPIE -DCANONICALIZATION_FOR_MATHN -I. -I.ext/include/x86_64-linux -I./include -I. -I./enc/unicode/12.1.0
CPPFLAGS =
DLDFLAGS = -Wl,--compress-debug-sections=zlib -fstack-protector-strong -pie
SOLIBS = -lz -lpthread -lrt -l

(中略)

transform_mjit_header: SKIPPED to transform putchar_unlocked
transform_mjit_header: SKIPPED to transform putc_unlocked
transform_mjit_header: SKIPPED to transform fputc_unlocked
transform_mjit_header: SKIPPED to transform putchar
transform_mjit_header: SKIPPED to transform getchar_unlocked
transform_mjit_header: SKIPPED to transform getc_unlocked
transform_mjit_header: SKIPPED to transform fgetc_unlocked
transform_mjit_header: SKIPPED to transform getchar
ln -sf ../../../.ext/include/x86_64-linux/rb_mjit_min_header-2.7.6.h include/ruby-2.7.0/x86_64-linux/rb_mjit_min_header-2.7.6.h
ubuntu@ip-172-29-0-169:~/ruby-2.7.6$

インストールしたところ openssl のエラーになりました。

ubuntu@ip-172-29-0-169:~/ruby-2.7.6$ sudo make install
./revision.h unchanged
generating x86_64-linux-fake.rb
x86_64-linux-fake.rb updated
        BASERUBY = echo executable host ruby is required.  use --with-baseruby option.; false
        CC = gcc
        LD = ld

(中略)

Traceback (most recent call last):
        11: from ./tool/rbinstall.rb:947:in `<main>'
        10: from ./tool/rbinstall.rb:947:in `each'
         9: from ./tool/rbinstall.rb:950:in `block in <main>'
         8: from ./tool/rbinstall.rb:799:in `block in <main>'
         7: from ./tool/rbinstall.rb:835:in `install_default_gem'
         6: from ./tool/rbinstall.rb:835:in `each'
         5: from ./tool/rbinstall.rb:845:in `block in install_default_gem'
         4: from ./tool/rbinstall.rb:279:in `open_for_install'
         3: from ./tool/rbinstall.rb:846:in `block (2 levels) in install_default_gem'
         2: from /home/ubuntu/ruby-2.7.6/lib/rubygems/specification.rb:2430:in `to_ruby'
         1: from /home/ubuntu/ruby-2.7.6/lib/rubygems/core_ext/kernel_require.rb:83:in `require'
/home/ubuntu/ruby-2.7.6/lib/rubygems/core_ext/kernel_require.rb:83:in `require': cannot load such file -- openssl (LoadError)
make: *** [uncommon.mk:380: do-install-nodoc] Error 1
ubuntu@ip-172-29-0-169:~/ruby-2.7.6$

rbenv のエラー

次に、rbenv からインストールを試しました。
まずは、rbenv を、Github の READ ME を見ながらインストールしました。

ubuntu@ip-172-29-0-173:~$ sudo apt install rbenv
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  fonts-lato icu-devtools javascript-common libicu-dev libjs-jquery libruby3.0 libsqlite3-dev libxml2-dev libxslt1-dev rake ruby ruby-build ruby-net-telnet ruby-rubygems
  ruby-xmlrpc ruby3.0 rubygems-integration unzip zip
Suggested packages:
  icu-doc sqlite3-doc pkg-config ri ruby-dev bison bundler
The following NEW packages will be installed:
  fonts-lato icu-devtools javascript-common libicu-dev libjs-jquery libruby3.0 libsqlite3-dev libxml2-dev libxslt1-dev rake rbenv ruby ruby-build ruby-net-telnet
  ruby-rubygems ruby-xmlrpc ruby3.0 rubygems-integration unzip zip
0 upgraded, 20 newly installed, 0 to remove and 21 not upgraded.
Need to get 22.6 MB of archives.
After this operation, 95.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

(中略)

No VM guests are running outdated hypervisor (qemu) binaries on this host.
ubuntu@ip-172-29-0-173:~$

インストール手順に ruby 2.7.4 と記載されているので、2.7.4 を選択してみましたが、候補にありませんでした。

ubuntu@ip-172-29-0-173:~$ rbenv -v
rbenv 1.1.2
ubuntu@ip-172-29-0-173:~$ rbenv install -list | grep 2.7
1.8.6-p287
2.0.0-p247
2.2.7
2.7.0-dev
2.7.0-preview1
2.7.0-preview2
2.7.0-preview3
2.7.0-rc1
2.7.0-rc2
2.7.0
2.7.1
jruby-9.2.7.0
rbx-2.2.7
rbx-2.7
rbx-2.71828182
ubuntu@ip-172-29-0-169:~$ rbenv install 2.7.1
/tmp/ruby-build.20220505221552.13843.qFMEUc ~
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...

インストールを試みましたがプロンプトがなかなか返ってこず、セッションマネージャーが切れてしまいました。20 分以上かかったようです。一時的に 60 分に変更して再度実行。

次は -v オプションをつけて実行しました。が、
「BUILD FAILED」しました。
OpenSSL 関連のエラーと gcc のコマンドラインオプションが理解できないエラーが含まれていました。

ubuntu@ip-172-29-0-169:~$ rbenv install 2.7.1 -v
/tmp/ruby-build.20220505221552.13843.qFMEUc ~
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...

(中略)

ossl_pkey_rsa.c: At top level:
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
make[2]: *** [Makefile:313: ossl_pkey_rsa.o] Error 1
make[2]: Leaving directory '/tmp/ruby-build.20220505221552.13843.qFMEUc/ruby-2.7.1/ext/openssl'
make[1]: *** [exts.mk:251: ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
linking shared-object etc.so
make[2]: Leaving directory '/tmp/ruby-build.20220505221552.13843.qFMEUc/ruby-2.7.1/ext/etc'
make[1]: Leaving directory '/tmp/ruby-build.20220505221552.13843.qFMEUc/ruby-2.7.1'
make: *** [uncommon.mk:295: build-ext] Error 2

BUILD FAILED (Ubuntu 22.04 using ruby-build 20200401)

Inspect or clean up the working tree at /tmp/ruby-build.20220505221552.13843.qFMEUc
Results logged to /tmp/ruby-build.20220505221552.13843.log

Last 10 log lines:
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
make[2]: *** [Makefile:313: ossl_pkey_rsa.o] Error 1
make[2]: Leaving directory '/tmp/ruby-build.20220505221552.13843.qFMEUc/ruby-2.7.1/ext/openssl'
make[1]: *** [exts.mk:251: ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
linking shared-object etc.so
make[2]: Leaving directory '/tmp/ruby-build.20220505221552.13843.qFMEUc/ruby-2.7.1/ext/etc'
make[1]: Leaving directory '/tmp/ruby-build.20220505221552.13843.qFMEUc/ruby-2.7.1'
make: *** [uncommon.mk:295: build-ext] Error 2
ubuntu@ip-172-29-0-169:~$

このエラーは、Github に記載されていました。OpenSSL 1.1 にしないといけないようですが、OpenSSL のバージョンが 3.0.2 なのでエラー内容が合致するのか確証が持てませんでした。

ubuntu@ip-172-29-0-173:~$ openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
ubuntu@ip-172-29-0-173:~$

ひとまず環境変数「RUBY_CONFIGURE_OPTS」を出力して、再度実行しましたが、(今回は -v をつけて進捗を確認しました。) やっぱりエラーに。OpenSSL のバージョンが 3.0.2 になっているのが原因な気がしました。

Redmine 5.0 をインストールすることに

Ruby 2.x.x のインストールが全般的に上手くいかないため、Ruby 3 が利用できる Redmine 5.0 をインストールしてみました。

冒頭の手順でインスタンスを作成して、セッションマネージャー経由で接続しました。
apt update を実施しました。
※ apparmor を無効にするとインスタンスが起動しなったのでご注意ください!

$ sudo -i
root@ip-172-29-0-37:~# su - ubuntu
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ip-172-29-0-37:~$ sudo apt update
Get:1 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:2 http://ap-northeast-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease [109 kB]

(中略)

Fetched 21.4 MB in 3s (7192 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
26 packages can be upgraded. Run 'apt list --upgradable' to see them.
ubuntu@ip-172-29-0-37:~$

UTC+9 にして

ubuntu@ip-172-29-0-37:~$ sudo timedatectl set-timezone Asia/Tokyo
ubuntu@ip-172-29-0-37:~$

redmine ユーザーを作成しました。

ubuntu@ip-172-29-0-37:~$ sudo adduser redmine
Adding user `redmine' ...
Adding new group `redmine' (1002) ...
Adding new user `redmine' (1002) with group `redmine' ...
Creating home directory `/home/redmine' ...
Copying files from `/etc/skel' ...
New password: <パスワードを入力>
Retype new password: <再度、パスワードを入力>
passwd: password updated successfully
Changing the user information for redmine
Enter the new value, or press ENTER for the default
        Full Name []: Redmine User
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y
ubuntu@ip-172-29-0-37:~$

作成した redmine ユーザーに sudo 権限を付与してログインし直しました。

ubuntu@ip-172-29-0-37:~$ exit
logout
ubuntu@ip-172-29-0-37:~# gpasswd -a redmine sudo
root@ip-172-29-0-37:~# su - redmine
redmine@ip-172-29-0-37:~$

記載されているライブラリーをインストール。

redmine@ip-172-29-0-82:~$ sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev ruby-dev libmysqlclient-dev -y
[sudo] password for redmine:
Reading package lists... Done

(中略)

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
redmine@ip-172-29-0-220:~$

上のインストールで Ruby 3.0.2 が入りました。

redmine@ip-172-29-0-37:~$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
redmine@ip-172-29-0-37:~$

MySQL インストール

Redmine 4.2 の手順はポスグレだったのですが、こちらは MySQL だったので、MySQL をインストールしました。

redmine@ip-172-29-0-37:~$ sudo apt install mysql-server -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:

(中略)

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
redmine@ip-172-29-0-37:~$

redmine データベースを作成しました。
rdusr ユーザーも作成しました。

redmine@ip-172-29-0-37:~$ sudo mysql -h localhost -u root -p
Enter password: <パスワードは空欄で通ります>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.29-0ubuntu0.22.04.2 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> CREATE DATABASE redmine CHARACTER SET utf8mb4;
Query OK, 1 row affected (0.01 sec)

mysql> CREATE USER 'rdusr'@'%' IDENTIFIED BY '<パスワード>';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT SELECT, UPDATE, DELETE, INSERT, CREATE, DROP, INDEX, ALTER, LOCK TABLES, EXECUTE, CREATE TEMPORARY TABLES, TRIGGER, CREATE VIEW, SHOW VIEW, EVENT ON redmine.* TO 'rdusr'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> quit;
Bye
redmine@ip-172-29-0-37:~$

Redmine インストール

redmine 5.0.0 をダウンロードして解凍。

redmine@ip-172-29-0-37:~$ wget https://www.redmine.org/releases/redmine-5.0.0.tar.gz
--2022-05-08 16:41:28--  https://www.redmine.org/releases/redmine-5.0.0.tar.gz
Resolving www.redmine.org (www.redmine.org)... 46.4.101.126
Connecting to www.redmine.org (www.redmine.org)|46.4.101.126|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3101059 (3.0M) [application/x-gzip]
Saving to: ‘redmine-5.0.0.tar.gz’

redmine-5.0.0.tar.gz               100%[===============================================================>]   2.96M  1016KB/s    in 3.0s

2022-05-08 16:41:32 (1016 KB/s) - ‘redmine-5.0.0.tar.gz’ saved [3101059/3101059]

redmine@ip-172-29-0-37:~$ tar xf redmine-5.0.0.tar.gz
redmine@ip-172-29-0-37:~$

ディレクトリー作成。

redmine@ip-172-29-0-37:~$ cd redmine-5.0.0/
redmine@ip-172-29-0-37:~/redmine-5.0.0$ mkdir tmp/pdf
redmine@ip-172-29-0-37:~/redmine-5.0.0$

database.yml ファイルをサンプルからコピーして作成しました。

redmine@ip-172-29-0-37:~/redmine-5.0.0$ cp config/database.yml.example config/database.yml
redmine@ip-172-29-0-37:~/redmine-5.0.0$ vi config/database.yml

production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: rdusr
  password: "<パスワード>"
  # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
  encoding: utf8mb4

bundler をインストール。

redmine@ip-172-29-0-37:~/redmine-5.0.0$ sudo apt install ruby-bundler
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

(中略)

No VM guests are running outdated hypervisor (qemu) binaries on this host.

redmine@ip-172-29-0-37:~/redmine-5.0.0$

手順通り、development と test を除外して bundler install しました。パスワードが求められたので入力。

redmine@ip-172-29-0-37:~/redmine-5.0.0$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/bin/openssl"
redmine@ip-172-29-0-37:~/redmine-5.0.0$ bundle install --without mysql2
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies.....
Using rake 13.0.6
Following files may not be writable, so sudo is needed:
  /usr/local/bin

(中略)

  Password:

(中略)

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.
redmine@ip-172-29-0-220:~/redmine-5.0.0$

セッションハイジャックを防ぐために、セッション情報を格納するcookieをエンコードするための鍵を生成。

redmine@ip-172-29-0-37:~/redmine-5.0.0$ bundle exec rake generate_secret_token
redmine@ip-172-29-0-37:~/redmine-5.0.0$

bundler によるテーブル作成

テーブルを作成するクエリーが大量に流れます。

redmine@ip-172-29-0-37:~/redmine-5.0.0$ RAILS_ENV=production bundle exec rake db:migrate
== 1 Setup: migrating =========================================================
-- create_table("attachments", {:options=>"ENGINE=InnoDB", :force=>true, :id=>:integer})
-> 0.0291s
-- create_table("auth_sources", {:options=>"ENGINE=InnoDB", :force=>true, :id=>:integer})

(中略)

redmine@ip-172-29-0-37:~/redmine-5.0.0$

デフォルトデータをデータベースに登録します。ja を指定しました。

redmine@ip-172-29-0-37:~/redmine-5.0.0$ RAILS_ENV=production bundle exec rake redmine:load_default_data

Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, es-PA, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk,mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja

Default configuration data loaded.
redmine@ip-172-29-0-37:~/redmine-5.0.0$

Puma インストール

権限を修正。

redmine@ip-172-29-0-37:~/redmine-5.0.0$ sudo chown -R redmine:redmine files log tmp public/plugin_assets
redmine@ip-172-29-0-37:~/redmine-5.0.0$ sudo chmod -R 755 files log tmp public/plugin_assets

Passenger をインストール。

redmine@ip-172-29-0-37:~/redmine-5.0.0$ sudo gem install passenger
Fetching passenger-6.0.13.gem
Building native extensions. This could take a while...
Successfully installed passenger-6.0.13
Parsing documentation for passenger-6.0.13
Installing ri documentation for passenger-6.0.13
Done installing documentation for passenger after 34 seconds
1 gem installed
redmine@ip-172-29-0-37:~/redmine-5.0.0$

Gemfile の最下部に puma を追記して、bundler インストール。
途中、パスワードを求められ入力して進めたところ完了しました。

redmine@ip-172-29-0-220:~/redmine-5.0.0$ vi Gemfile

gem 'puma'

redmine@ip-172-29-0-220:~/redmine-5.0.0$ bundle install
Your Gemfile lists the gem puma (>= 0) more than once.
You should probably keep only one of them.

(中略)

  Password:
Installing puma 5.6.4 with native extensions
Bundle complete! 43 Gemfile dependencies, 74 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
redmine@ip-172-29-0-220:~/redmine-5.0.0$

Puma サーバーを起動したところ、

redmine@ip-172-29-0-220:~/redmine-5.0.0$ bundle exec puma -e production
Puma starting in single mode...
* Puma version: 5.6.4 (ruby 3.0.2-p107) ("Birdie's Version")
*  Min threads: 0
*  Max threads: 5
*  Environment: production
*          PID: 6538
* Listening on http://0.0.0.0:9292

9292 ポートにてアクセスできました。

見た目は 4.2 とほとんど変わりませんでしたが、二段階認証が使えるようになっていました。

GW 中にリベンジできたのと、最新版が触れたのは大きな収穫でした。

この記事が気に入ったらサポートをしてみませんか?