1.この記事の内容
RasberryPi上にタスク管理ツールであるRedmine環境を自宅内のローカルサーバとして構築した手順を記載します.
個人のタスク管理の用途での環境構築ですが,チームのタスク管理の参考にもなればと思います.
1-1.使用環境
- Raspberry Pi 1 Model B
- インストールするRedmineのバージョン:4.1.1
2.背景
環境構築やプログラミング等にかかる作業時間の記録の目的でタスク管理ツールを調査した結果,OSSでLinux上に導入可能なRedmineを利用することにしました.
RaspberryPiが余っていたため,自宅内Redmineサーバとしての有効活用を考え,古い型番を採用しています.
2-1.Redmine環境構築
2-1-1.SDカードにOSを書き込む
Raspberry Pi公式サイト(https://www.raspberrypi.org/software/ )からRaspberry Pi Imagerをダウンロードし,RaspbianをSDカードへ書き込みます.
2-1-2.Redmineに必要なパッケージのインストール
- Ruby 2.5
$ sudo apt install libssl-dev libreadline-dev
$ sudo git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ sudo git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ sudo ~/.rbenv/bin/rbenv rehash
$ sudo chmod -R a+w ~/.rbenv
$ rbenv install --list
2.5.8
2.6.6
2.7.2
3.0.0
jruby-9.2.14.0
mruby-2.1.2
rbx-5.0
truffleruby-20.3.0
truffleruby+graalvm-20.3.0
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.
$ rbenv install 2.5.8
Downloading ruby-2.5.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.bz2
Installing ruby-2.5.8...
WARNING: ruby-2.5.8 is nearing its end of life.
It only receives critical security updates, no bug fixes.
Installed ruby-2.5.8 to /home/pi/.rbenv/versions/2.5.8
$ rbenv global 2.5.8
$ rbenv rehash
$ ruby --version
ruby 2.5.8p224 (2020-03-31 revision 67882) [armv6l-linux-eabihf]
- Rails 5.2
インストール途中で強制終了されるが,気にせずコマンドを実行するとインストール正常(?)終了します.
$ gem list rails -rea
*** REMOTE GEMS ***
rails (6.1.0, 6.0.3.4, 6.0.3.3, 6.0.3.2, 6.0.3.1, 6.0.3, 6.0.2.2, 6.0.2.1, 6.0.2, 6.0.1, 6.0.0, 5.2.4.4, 5.2.4.3, 5.2.4.2, 5.2.4.1, 5.2.4, 5.2.3, 5.2.2.1, 5.2.2, 5.2.1.1, 5.2.1, 5.2.0, 5.1.7, 5.1.6.2, 5.1.6.1, 5.1.6, 5.1.5, 5.1.4, 5.1.3, 5.1.2, 5.1.1, 5.1.0, 5.0.7.2, 5.0.7.1, 5.0.7, 5.0.6, 5.0.5, 5.0.4, 5.0.3, 5.0.2, 5.0.1, 5.0.0.1, 5.0.0, 4.2.11.3, 4.2.11.2, 4.2.11.1, 4.2.11, 4.2.10, 4.2.9, 4.2.8, 4.2.7.1, 4.2.7, 4.2.6, 4.2.5.2, 4.2.5.1, 4.2.5, 4.2.4, 4.2.3, 4.2.2, 4.2.1, 4.2.0, 4.1.16, 4.1.15, 4.1.14.2, 4.1.14.1, 4.1.14, 4.1.13, 4.1.12, 4.1.11, 4.1.10, 4.1.9, 4.1.8, 4.1.7.1, 4.1.7, 4.1.6, 4.1.5, 4.1.4, 4.1.3, 4.1.2, 4.1.1, 4.1.0, 4.0.13, 4.0.12, 4.0.11.1, 4.0.11, 4.0.10, 4.0.9, 4.0.8, 4.0.7, 4.0.6, 4.0.5, 4.0.4, 4.0.3, 4.0.2, 4.0.1, 4.0.0, 3.2.22.5, 3.2.22.4, 3.2.22.3, 3.2.22.2, 3.2.22.1, 3.2.22, 3.2.21, 3.2.20, 3.2.19, 3.2.18, 3.2.17, 3.2.16, 3.2.15, 3.2.14, 3.2.13, 3.2.12, 3.2.11, 3.2.10, 3.2.9, 3.2.8, 3.2.7, 3.2.6, 3.2.5, 3.2.4, 3.2.3, 3.2.2, 3.2.1, 3.2.0, 3.1.12, 3.1.11, 3.1.10, 3.1.9, 3.1.8, 3.1.7, 3.1.6, 3.1.5, 3.1.4, 3.1.3, 3.1.2, 3.1.1, 3.1.0, 3.0.20, 3.0.19, 3.0.18, 3.0.17, 3.0.16, 3.0.15, 3.0.14, 3.0.13, 3.0.12, 3.0.11, 3.0.10, 3.0.9, 3.0.8, 3.0.7, 3.0.6, 3.0.5, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0, 2.3.18, 2.3.17, 2.3.16, 2.3.15, 2.3.14, 2.3.12, 2.3.11, 2.3.10, 2.3.9, 2.3.8, 2.3.7, 2.3.6, 2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.3, 2.2.2, 2.1.2, 2.1.1, 2.1.0, 2.0.5, 2.0.4, 2.0.2, 2.0.1, 2.0.0, 1.2.6, 1.2.5, 1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.6, 1.1.5, 1.1.4, 1.1.3, 1.1.2, 1.1.1, 1.1.0, 1.0.0, 0.14.4, 0.14.3, 0.14.2, 0.14.1, 0.13.1, 0.13.0, 0.12.1, 0.12.0, 0.11.1, 0.11.0, 0.10.1, 0.10.0, 0.9.5, 0.9.4.1, 0.9.4, 0.9.3, 0.9.2, 0.9.1, 0.9.0, 0.8.5, 0.8.0)
$ gem install rails -v '5.2.4'
Fetching: concurrent-ruby-1.1.7.gem (100%)
Successfully installed concurrent-ruby-1.1.7
Fetching: i18n-1.8.5.gem (100%)
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.
If you are upgrading your Rails application from an older version of Rails:
Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.
If you are starting a NEW Rails application, you can ignore this notice.
For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
Successfully installed i18n-1.8.5
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.9.gem (100%)
Successfully installed tzinfo-1.2.9
Fetching: activesupport-5.2.4.gem (100%)
Successfully installed activesupport-5.2.4
Fetching: rack-2.2.3.gem (100%)
/home/pi/.rbenv/rbenv.d/exec/gem-rehash/rubygems_plugin.rb:6: warning: Insecure world writable dir /home/pi/.rbenv in PATH, mode 040777
Successfully installed rack-2.2.3
Fetching: rack-test-1.1.0.gem (100%)
Successfully installed rack-test-1.1.0
Fetching: mini_portile2-2.4.0.gem (100%)
Successfully installed mini_portile2-2.4.0
Fetching: nokogiri-1.10.10.gem (100%)
Building native extensions. This could take a while...
Successfully installed nokogiri-1.10.10
Fetching: crass-1.0.6.gem (100%)
Successfully installed crass-1.0.6
・・・(中略)
Installing ri documentation for activerecord-5.2.4
Parsing documentation for globalid-0.4.2
Installing ri documentation for globalid-0.4.2
Parsing documentation for activejob-5.2.4
Installing ri documentation for activejob-5.2.4
Parsing documentation for mini_mime-1.0.2
Installing ri documentation for mini_mime-1.0.2
Parsing documentation for mail-2.7.1
強制終了
気にせず再度インストールコマンドを実行します.
$ gem install rails -v '5.2.4'
Successfully installed rails-5.2.4
Parsing documentation for rails-5.2.4
Installing ri documentation for rails-5.2.4
Done installing documentation for rails after 19 seconds
1 gem installed
$ rails --version
Rails 5.2.4
- データベース:PostgreSQL 11
pi@raspberrypi:~$ sudo apt-cache showpkg postgresql
Package: postgresql
Versions:
11+200+deb10u4 (/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_buster_main_binary-armhf_Packages)
Description Language:
File: /var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_buster_main_binary-armhf_Packages
MD5: bdff2d6e5b2a1dd00e72b3ed8729d9ac
Reverse Depends:
gnumed-server,postgresql 9.2
libreoffice-sdbc-postgresql,postgresql 8.4
otrs2,postgresql
・・・(以下略)
pi@raspberrypi:~$ sudo apt install postgresql='11+200+deb10u4'
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
libllvm7 libpq5 postgresql-11 postgresql-client-11 postgresql-client-common postgresql-common sysstat
提案パッケージ:
postgresql-doc postgresql-doc-11 libjson-perl isag
以下のパッケージが新たにインストールされます:
libllvm7 libpq5 postgresql postgresql-11 postgresql-client-11 postgresql-client-common postgresql-common sysstat
アップグレード: 0 個、新規インストール: 8 個、削除: 0 個、保留: 0 個。
27.0 MB のアーカイブを取得する必要があります。
この操作後に追加で 105 MB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf libllvm7 armhf 1:7.0.1-8+rpi3+deb10u2 [11.4 MB]
取得:2 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf libpq5 armhf 11.9-0+deb10u1 [150 kB]
取得:3 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf postgresql-client-common all 200+deb10u4 [85.1 kB]
取得:4 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf postgresql-client-11 armhf 11.9-0+deb10u1 [1,294 kB]
取得:5 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf postgresql-common all 200+deb10u4 [225 kB]
取得:6 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf postgresql-11 armhf 11.9-0+deb10u1 [13.3 MB]
取得:7 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf postgresql all 11+200+deb10u4 [61.1 kB]
取得:8 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf sysstat armhf 12.0.3-2 [513 kB]
27.0 MB を 11秒 で取得しました (2,540 kB/s)
パッケージを事前設定しています ...
以前に未選択のパッケージ libllvm7:armhf を選択しています。
(データベースを読み込んでいます ... 現在 100426 個のファイルとディレクトリがインストールされています。)
.../0-libllvm7_1%3a7.0.1-8+rpi3+deb10u2_armhf.deb を展開する準備をしています ...
・・・(中略)
update-alternatives: /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) を提供するために自動モードで /usr/share/postgresql/11/man/man1/postmaster.1.gz を使います
postgresql (11+200+deb10u4) を設定しています ...
systemd (241-7~deb10u5+rpi1) のトリガを処理しています ...
man-db (2.8.5-2) のトリガを処理しています ...
libc-bin (2.28-10+rpi1) のトリガを処理しています ...
pi@raspberrypi:~$ sudo passwd postgres
新しいパスワード:
新しいパスワードを再入力してください:
passwd: パスワードは正しく更新されました
pi@raspberrypi:~$ su - postgres
パスワード:
2-1-3.Redmineのインストール
Step1 - Redmine本体のインストール
Redmine公式サイトのダウンロードページから最新版をダウンロードして解凍します.
pi@raspberrypi:~ $ wget https://www.redmine.org/releases/redmine-4.1.1.tar.gz
--2020-12-30 21:33:05-- https://www.redmine.org/releases/redmine-4.1.1.tar.gz
www.redmine.org (www.redmine.org) をDNSに問いあわせています... 46.4.101.126
www.redmine.org (www.redmine.org)|46.4.101.126|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 2712056 (2.6M) [application/x-gzip]
`redmine-4.1.1.tar.gz' に保存中
redmine-4.1.1.tar.gz 100%[=================================================================>] 2.59M 1000KB/s 時間 2.6s
2020-12-30 21:33:10 (1000 KB/s) - `redmine-4.1.1.tar.gz' へ保存完了 [2712056/2712056]
pi@raspberrypi:~ $ tar -zxf redmine-4.1.1.tar.gz
pi@raspberrypi:~ $ ls
Bookshelf Desktop Documents Downloads Music Pictures Public Templates Videos redmine-4.1.1 redmine-4.1.1.tar.gz
Step 2 - 空のデータベースとユーザーの作成
本記事では,Redmineの手順に倣ってデータベース名とユーザ名をredmineとした手順で紹介します.
postgres@raspberrypi:~$ psql
psql (11.9 (Raspbian 11.9-0+deb10u1))
"help" でヘルプを表示します。
postgres=# CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD '[パスワード]' NOINHERIT VALID UNTIL 'infinity';
CREATE ROLE
postgres=# CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;
CREATE DATABASE
postgres=# \q
postgres@raspberrypi:~$
postgres@raspberrypi:~$ exit
Step 3 - データベースに接続するための設定
pi@raspberrypi:~ $ cd redmine-4.1.1/config/
pi@raspberrypi:~/redmine-4.1.1/config $ cp database.yml.example database.yml
pi@raspberrypi:~/redmine-4.1.1/config $ vim database.yml
※MySQLをコメントアウトして,PostgreSQLを更新します.本記事ではredmineアカウントの例を記載しています.
--- config/database.yml.example 2020-04-07 02:00:48.000000000 +0900
+++ config/database.yml 2020-12-31 04:52:33.194183117 +0900
@@ -2,43 +2,43 @@
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
-production:
- adapter: mysql2
- database: redmine
- host: localhost
- username: root
- password: ""
- # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
- encoding: utf8mb4
-
-development:
- adapter: mysql2
- database: redmine_development
- host: localhost
- username: root
- password: ""
- # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
- encoding: utf8mb4
-
-# Warning: The database defined as "test" will be erased and
-# re-generated from your development database when you run "rake".
-# Do not set this db to the same as development or production.
-test:
- adapter: mysql2
- database: redmine_test
- host: localhost
- username: root
- password: ""
- # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
- encoding: utf8mb4
-
-# PostgreSQL configuration example
#production:
-# adapter: postgresql
+# adapter: mysql2
# database: redmine
# host: localhost
-# username: postgres
-# password: "postgres"
+# username: root
+# password: ""
+# # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
+# encoding: utf8mb4
+#
+#development:
+# adapter: mysql2
+# database: redmine_development
+# host: localhost
+# username: root
+# password: ""
+# # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
+# encoding: utf8mb4
+#
+## Warning: The database defined as "test" will be erased and
+## re-generated from your development database when you run "rake".
+## Do not set this db to the same as development or production.
+#test:
+# adapter: mysql2
+# database: redmine_test
+# host: localhost
+# username: root
+# password: ""
+# # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
+# encoding: utf8mb4
+
+# PostgreSQL configuration example
+production:
+ adapter: postgresql
+ database: redmine
+ host: localhost
+ username: redmine
+ password: "[パスワード]"
# SQLite3 configuration example
#production:
pi@raspberrypi:~/redmine-4.1.1/config $ cd ..
Step 4 - 依存するソフトウェアのインストール
pi@raspberrypi:~/redmine-4.1.1 $ sudo apt install libpq-dev
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
提案パッケージ:
postgresql-doc-11
以下のパッケージが新たにインストールされます:
libpq-dev
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
150 kB のアーカイブを取得する必要があります。
この操作後に追加で 570 kB のディスク容量が消費されます。
取得:1 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian buster/main armhf libpq-dev armhf 11.9-0+deb10u1 [150 kB]
150 kB を 1秒 で取得しました (115 kB/s)
以前に未選択のパッケージ libpq-dev を選択しています。
(データベースを読み込んでいます ... 現在 102509 個のファイルとディレクトリがインストールされています。)
.../libpq-dev_11.9-0+deb10u1_armhf.deb を展開する準備をしています ...
libpq-dev (11.9-0+deb10u1) を展開しています...
libpq-dev (11.9-0+deb10u1) を設定しています ...
man-db (2.8.5-2) のトリガを処理しています ...
pi@raspberrypi:~/redmine-4.1.1 $ bundle install --without development test
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local without 'development test'`, and stop using this flag
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...........................................................................................................................................
Using rake 13.0.3
Using concurrent-ruby 1.1.7
Using i18n 1.6.0
Using minitest 5.14.2
Using thread_safe 0.3.6
Using tzinfo 1.2.9
Using activesupport 5.2.4.2
Using builder 3.2.4
Using erubi 1.10.0
・・・(中略)
Fetching roadie 4.0.0
Installing roadie 4.0.0
Fetching roadie-rails 2.1.1
Installing roadie-rails 2.1.1
Fetching rouge 3.12.0
Installing rouge 3.12.0
Bundle complete! 31 Gemfile dependencies, 59 gems now installed.
Gems in the groups development, test and rmagick were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Step 5 - セッションストア秘密鍵の生成
pi@raspberrypi:~/redmine-4.1.1 $ bundle exec rake generate_secret_token
Step 6 - データベースのテーブル等の作成
pi@raspberrypi:~/redmine-4.1.1 $ RAILS_ENV=production bundle exec rake db:migrate
== 1 Setup: migrating =========================================================
-- create_table("attachments", {:force=>true, :id=>:integer})
-> 0.2152s
-- create_table("auth_sources", {:force=>true, :id=>:integer})
-> 0.1413s
-- create_table("custom_fields", {:force=>true, :id=>:integer})
-> 0.1997s
-- create_table("custom_fields_projects", {:id=>false, :force=>true})
-> 0.0785s
-- create_table("custom_fields_trackers", {:id=>false, :force=>true})
-> 0.0790s
-- create_table("custom_values", {:force=>true, :id=>:integer})
-> 0.1837s
-- create_table("documents", {:force=>true, :id=>:integer})
-> 0.1323s
-- add_index("documents", ["project_id"], {:name=>"documents_project_id"})
-> 0.0764s
・・・(中略)
== 20190510070108 AddUniqueIdToImportItems: migrating =========================
-- change_table(:import_items)
-> 0.0664s
== 20190510070108 AddUniqueIdToImportItems: migrated (0.0718s) ================
== 20190620135549 ChangeRolesNameLimit: migrating =============================
-- change_column(:roles, :name, :string, {:limit=>255, :default=>""})
-> 0.0317s
== 20190620135549 ChangeRolesNameLimit: migrated (0.0376s) ====================
Step 7 - デフォルトデータ
実行途中で言語選択を求められるので,'ja'(日本語)を選択します.
pi@raspberrypi:~/redmine-4.1.1 $ 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.
Step 8 - ファイルシステムのパーミッション
Redmineアプリケーションを実行するユーザは'pi'とします.
pi@raspberrypi:~/redmine-4.1.1 $ mkdir -p tmp tmp/pdf public/plugin_assets
pi@raspberrypi:~/redmine-4.1.1 $ sudo chown -R pi:pi files log tmp public/plugin_assets
pi@raspberrypi:~/redmine-4.1.1 $ sudo chmod -R 755 files log tmp public/plugin_assets
Step 9 - インストールの確認
pi@raspberrypi:~/redmine-4.1.1 $ bundle exec rails server webrick -e production
=> Booting WEBrick
=> Rails 5.2.4.2 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
[2020-12-31 05:23:13] INFO WEBrick 1.4.2
[2020-12-31 05:23:13] INFO ruby 2.5.8 (2020-03-31) [armv6l-linux-eabihf]
[2020-12-31 05:23:13] INFO WEBrick::HTTPServer#start: pid=11271 port=3000
・・・(以下略)
Step 10 - ログイン
Raspberry Pi上のブラウザで「http://localhost:3000」にアクセスするか,同じネットワーク上のPCなどから「http://[IPアドレス]:3000」にアクセスするとRedmineのホーム画面が表示されます.
ページ右上の「ログイン」をクリックして,システム管理者アカウントでログインします.
- ログインID:admin
- パスワード:admin
ログイン後,初期パスワードを変更して利用準備完了です.
3.さいごに
RasberryPiでのRedmine環境構築について記載しました.
概ね公式手順通りでインストールすることができました.
ユーザ追加やプロジェクト追加の作業を実施しましたが,反応が遅い印象です.
個人で使用する分には問題ないかもしれませんが,チームで使用する場合はきちんとサーバを用意するのがよさそうです.
少人数での利用であれば,Raspberry Pi 4 Model Bくらいでもよいかもしれません.
定量的な性能計測は気が向けば.