Redmine5.0 初期導入

# はじめに

この記事は、Bitnami Redmine 5.0 をオフライン環境に導入するためにトライしたあれこれを書いていくものです。(適宜追記していきます)

# 使ったもの

Bitnami Redmine のVMイメージ(ova) 5.0.0.1-r1 ※執筆時点の最新
Virtual Box 6.1.14

# 色々入れる前に4.2と5.0の差

触ってみて確認しているだけでオフィシャルな情報を確認していないのですが、以下のような差が今のところ見られています。

## ディレクトリ構成が違う

いろいろ導入する先が変更になっています。ある意味シンプルになっているのかな。
4.2  `/opt/bitnami/apps/redmine/htdocs`
5.0  `/bitnami/redmine`

ちなみに`/bitnami/redmine`配下にはこんなのが入ってます。
```
config
files
plugins
public
```

## rubyのバージョンが3.0になっている

これがどういう影響を及ぼすのかはわかりません。

# ゲストOSの設定

## SSHの有効化


## エイリアス設定


## タイムゾーン設定


## 日本語フォント導入

pdfを出力する際に日本語になるように


# ログファイルの権限修正

今後いろいろオペレーションをするうえで毎回エラーが出るのでパーミッションを変えておきます。
```
bitnami@debian:~/redmine$ chmod sudo chmod 666 /opt/bitnami/redmine/log/production.log
```

## ダミーデータ構築

いろいろテストするうえでダミーデータがあったほうがはかどるのでダミーデータを作ります。
Redmine/RedMicaの動作確認・デモ用にテスト用のデータ（チケット、Wiki、フォーラム、…）を投入する
を参考にさせていただきました。

redmineのディレクトリに移動してから実行します。
```
$ cd /opt/bitnami/redmine
$ bin/rails db:fixtures:load
```

# バナー削除

[公式の案内](https://docs.bitnami.com/aws/how-to/bitnami-remove-banner/) に従って
バナー削除コマンドを投入します。(4.xのときとはパスが違う)
```
sudo /opt/bitnami/apps/APPNAME/bnconfig --disable_banner 1
```

反映のためにApacheの再起動
```
sudo systemctl restart apache
```

# プラグイン導入

ここからが本番。


## worktime-plugin

[GitHubのページ](https://github.com/tkusukawa/redmine_work_time)よりダウンロードして、puluginsに導入。

```
cd /opt/bitnami/redmine/
git clone https://github.com/tkusukawa/redmine_work_time.git
cd ..
RAILS_ENV=production bundle exec rake redmine:plugins:migrate
```

有効化するためのコマンドを実行したところ以下のエラーが出ました。
```
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /opt/bitnami/redmine/db/schema.rb
```

パーミッションを確認してみると `daemon:daemon`になってる。どうしてこうなった。
```
bitnami@debian:/opt/bitnami/redmine$ ll /opt/bitnami/redmine/db/schema.rb
-rw-r--r-- 1 daemon daemon 27475 Jun  8 12:53 /opt/bitnami/redmine/db/schema.rb
```

パーミッションを変えて再実行したらうまくいきました。
```
bitnami@debian:/opt/bitnami/redmine$ sudo chown bitnami:daemon /opt/bitnami/redmine/db/schema.rb
bitnami@debian:/opt/bitnami/redmine$bundle exec rake redmine:plugins:migrate --trace
** Invoke redmine:plugins:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:plugins:migrate
** Invoke db:schema:dump (first_time)
** Invoke db:load_config (first_time)
** Invoke environment
** Execute db:load_config
** Execute db:schema:dump
bitnami@debian:/opt/bitnami/redmine$
```

# redmine_knowledgebase

導入コマンド
```
bundle install
bundle exec rake redmine:plugins:migrate NAME=redmine_knowledgebase
```

怒られた。

```
bitnami@debian:/opt/bitnami/redmine$ bundle install
Bundler 2.3.16 is running, but your lockfile was generated with 2.3.13. Installing Bundler 2.3.13 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.3.13
Installing bundler 2.3.13
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

If this is a development machine, remove the /opt/bitnami/redmine/Gemfile freeze
by running `bundle config unset deployment`.

The dependencies in your gemfile changed

You have added to the Gemfile:
* redmine_crm
* ya2yaml
* awesome_nested_set
```

対処します。
```
bundle config unset deployment
```

インストールできました。

追加されたのはこれ。
```
Installing awesome_nested_set 3.5.0　　★追加
Installing liquid 2.6.3　　　　★追加
Installing redmine_crm 0.0.57　　　★追加
Installing ya2yaml 0.31　　　　★追加
```

<details><summary>全文</summary>

```
bitnami@debian:/opt/bitnami/redmine$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies.........
Using rake 13.0.6
Using concurrent-ruby 1.1.10
Using i18n 1.10.0
Using minitest 5.16.1
Using tzinfo 2.0.4
Using zeitwerk 2.6.0
Using activesupport 6.1.6
Using builder 3.2.4
Using erubi 1.10.0
Using racc 1.6.0
Using nokogiri 1.13.6 (x86_64-linux)
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.18.0
Using rails-html-sanitizer 1.4.3
Using actionview 6.1.6
Using rack 2.2.3.1
Using rack-test 1.1.0
Using actionpack 6.1.6
Using nio4r 2.5.8
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.5
Using actioncable 6.1.6
Using globalid 1.0.0
Using activejob 6.1.6
Using activemodel 6.1.6
Using activerecord 6.1.6
Using marcel 1.0.2
Using mini_mime 1.1.2
Using activestorage 6.1.6
Using mail 2.7.1
Using actionmailbox 6.1.6
Using actionmailer 6.1.6
Using method_source 1.0.0
Using thor 1.2.1
Using railties 6.1.6
Using actionpack-xml_parser 2.0.1
Using actiontext 6.1.6
Using public_suffix 4.0.7
Using addressable 2.8.0
Fetching awesome_nested_set 3.5.0
Installing awesome_nested_set 3.5.0　　★追加
Using bundler 2.3.13
Using chunky_png 1.4.0
Using commonmarker 0.23.4
Using css_parser 1.11.0
Using csv 3.2.3
Using html-pipeline 2.13.2
Using deckar01-task_list 2.3.2
Using digest 3.1.0
Using htmlentities 4.3.4
Fetching liquid 2.6.3
Installing liquid 2.6.3　　　　★追加
Using mini_magick 4.11.0
Using mysql2 0.5.4
Using timeout 0.3.0
Using net-protocol 0.1.3
Using strscan 3.0.3
Using net-imap 0.2.3
Using net-ldap 0.17.1
Using net-pop 0.1.1
Using net-smtp 0.3.1
Using passenger 6.0.14
Using pg 1.2.3
Using sprockets 4.0.3
Using sprockets-rails 3.4.2
Using rails 6.1.6
Using rbpdf-font 1.19.1
Using rbpdf 1.20.1
Using redcarpet 3.5.1
Using rubyzip 2.3.2
Fetching redmine_crm 0.0.57
Installing redmine_crm 0.0.57　　　★追加
Using request_store 1.5.1
Using rexml 3.2.5
Using roadie 5.0.1
Using roadie-rails 3.0.0
Using rotp 6.2.0
Using rouge 3.28.0
Using rqrcode_core 1.2.0
Using rqrcode 2.1.1
Using sanitize 6.0.0
Fetching ya2yaml 0.31
Installing ya2yaml 0.31　　　　★追加
Bundle complete! 48 Gemfile dependencies, 80 gems now installed.
Gems in the groups 'development', 'sqlite' and 'test' were not installed.
Bundled gems are installed into `./vendor/bundle`
bitnami@debian:/opt/bitnami/redmine$
```
</details>

改めて反映コマンド流します。

```
bundle exec rake redmine:plugins:migrate NAME=redmine_knowledgebase
```

ダメでした

<details><summary>エラーメッセージ</summary>

```
bitnami@debian:/opt/bitnami/redmine$ bundle exec rake redmine:plugins:migrate NAME=redmine_knowledgebase
rake aborted!
LoadError: cannot load such file -- listen
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:332:in `block in require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:299:in `load_dependency'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:332:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/evented_file_update_checker.rb:6:in `<top (required)>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:332:in `block in require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:299:in `load_dependency'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:332:in `require'
/opt/bitnami/redmine/config/environments/development.rb:58:in `block in <top (required)>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/railtie.rb:234:in `instance_eval'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/railtie.rb:234:in `configure'
/opt/bitnami/redmine/config/environments/development.rb:5:in `<top (required)>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:332:in `block in require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:299:in `load_dependency'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:332:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/engine.rb:571:in `block (2 levels) in <class:Engine>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/engine.rb:570:in `each'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/engine.rb:570:in `block in <class:Engine>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/initializable.rb:32:in `instance_exec'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/initializable.rb:32:in `run'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/initializable.rb:61:in `block in run_initializers'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/initializable.rb:50:in `each'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/initializable.rb:50:in `tsort_each_child'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/initializable.rb:60:in `run_initializers'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/application.rb:391:in `initialize!'
/opt/bitnami/redmine/config/environment.rb:16:in `<top (required)>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:332:in `block in require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:299:in `load_dependency'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.6/lib/active_support/dependencies.rb:332:in `require'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/application.rb:367:in `require_environment!'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/railties-6.1.6/lib/rails/application.rb:533:in `block in run_tasks_blocks'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:58:in `load'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:58:in `kernel_load'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:23:in `run'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:483:in `exec'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:31:in `dispatch'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:25:in `start'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/exe/bundle:48:in `block in <top (required)>'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/opt/bitnami/redmine/vendor/bundle/ruby/3.0.0/gems/bundler-2.3.13/exe/bundle:36:in `<top (required)>'
/opt/bitnami/redmine/bin/bundle:113:in `load'
/opt/bitnami/redmine/bin/bundle:113:in `<main>'
Tasks: TOP => redmine:plugins:migrate => environment
(See full trace by running task with --trace)
bitnami@debian:/opt/bitnami/redmine$
```
</details>