■Redmine 5.0 をUbuntu 22.04 LTSにインストールする手順
■OSの設定
・ja_JP.UTF-8ロケールの作成
kokaki@skynew:~$ sudo locale-gen ja_JP.UTF-8
Generating locales (this might take a while)...
ja_JP.UTF-8... done
Generation complete.
kokaki@skynew:~$ locale -a
C
C.utf8
POSIX
ja_JP.utf8
■必要なパッケージのインストール
・パッケージ管理システムのデータベースを最新に更新
kokaki@skynew:~$ sudo apt update -y
:
:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
14 packages can be upgraded. Run 'apt list --upgradable' to see them.
・RubyとPassengerのビルドに必要な開発ツールやヘッダファイルのインストール
kokaki@skynew:~$ 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
build-essential is already the newest version (12.9ubuntu3).
libffi-dev is already the newest version (3.4.2-4).
libreadline-dev is already the newest version (8.1.2-1).
libyaml-dev is already the newest version (0.2.2-1build2).
libcurl4-openssl-dev is already the newest version (7.81.0-1ubuntu1.15).
libssl-dev is already the newest version (3.0.2-0ubuntu1.13).
zlib1g-dev is already the newest version (1:1.2.11.dfsg-2ubuntu9.2).
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
・PostgreSQLとヘッダファイルのインストール
kokaki@skynew:~$ sudo apt install -y postgresql libpq-dev
:
:
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
update-alternatives: using /usr/share/postgresql/14/man/man1/postmaster.1.gz
to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Setting up postgresql (14+238) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
・Apacheとヘッダファイルのインストール
kokaki@skynew:~$ sudo apt install -y apache2 apache2-dev
:
:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
apache2 is already the newest version (2.4.52-1ubuntu4.7).
apache2-dev is already the newest version (2.4.52-1ubuntu4.7).
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
・日本語フォントのインストール
kokaki@skynew:~$ sudo apt install -y imagemagick fonts-takao-pgothic
:
:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
fonts-takao-pgothic is already the newest version (00303.01-3ubuntu1).
imagemagick is already the newest version (8:6.9.11.60+dfsg-1.3ubuntu0.22.04.3).
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
・そのほかのツールのインストール
kokaki@skynew:~$ sudo apt install -y subversion git
:
:
Preparing to unpack .../subversion_1.14.1-3ubuntu0.22.04.1_amd64.deb ...
Unpacking subversion (1.14.1-3ubuntu0.22.04.1) ...
Setting up libutf8proc2:amd64 (2.7.0-3) ...
Setting up libserf-1-1:amd64 (1.3.9-10ubuntu2) ...
Setting up libsvn1:amd64 (1.14.1-3ubuntu0.22.04.1) ...
Setting up subversion (1.14.1-3ubuntu0.22.04.1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
Processing triggers for man-db (2.10.2-1) ...
■Rubyのインストール
・ソースコードのダウンロード
kokaki@skynew:~$ curl -O https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.0M 100 21.0M 0 0 27.1M 0 --:--:-- --:--:-- --:--:-- 27.1M
・Rubyのビルド
kokaki@skynew:~$ tar xvf ruby-3.3.0.tar.gz
kokaki@skynew:~$ cd ruby-3.3.0/
kokaki@skynew:~/ruby-3.3.0$ ./configure --disable-install-doc
kokaki@skynew:~/ruby-3.3.0$ make
kokaki@skynew:~/ruby-3.3.0$ sudo make install
kokaki@skynew:~/ruby-3.3.0$ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
kokaki@skynew:~/ruby-3.3.0$ sudo ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
kokaki@skynew:~/ruby-3.3.0$ cd ..
■PostgreSQLの設定
・Redmine用ユーザーの作成
kokaki@skynew:~$ sudo -i -u postgres createuser -P redmine
Enter password for new role:(postgres)
Enter it again:(postgres)
・Redmine用データベースの作成
kokaki@skynew:~$ sudo -i -u postgres createdb -E UTF-8 -l ja_JP.UTF-8 -O redmine -T template0 redmine
■Redmineインストール
・Redmineのダウンロード
kokaki@skynew:~$ curl -O https://www.redmine.org/releases/redmine-5.1.1.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3169k 100 3169k 0 0 880k 0 0:00:03 0:00:03 --:--:-- 880k
kokaki@skynew:~$ tar zxvf redmine-5.1.1.tar.gz
kokaki@skynew:~$ sudo mv redmine-5.1.1/ /var/lib/redmine
kokaki@skynew:~$ sudo chown www-data /var/lib/redmine
kokaki@skynew:~$ cd /var/lib/redmine/
・データベースへの接続設定
kokaki@skynew:/var/lib/redmine$ sudo cp config/database.yml.example config/database.yml
kokaki@skynew:/var/lib/redmine$ sudo vi config/database.yml
# PostgreSQL configuration example
production:
adapter: postgresql
database: redmine
host: localhost
username: redmine
password: "postgres"
encoding: utf8
・設定ファイル config/configuration.yml の作成
kokaki@skynew:/var/lib/redmine$ sudo cp config/configuration.yml.example config/configuration.yml
kokaki@skynew:/var/lib/redmine$ sudo vi config/configuration.yml
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "localhost"
port: 25
domain: "kokaki.jp"
rmagick_font_path: /usr/share/fonts/truetype/takao-gothic/TakaoPGothic.ttf
・gemパッケージのインストール
kokaki@skynew:/var/lib/redmine$ sudo 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 without 'development test'`, and stop using this flag
Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users on this machine.
Your Ruby version is 3.3.0, but your Gemfile specified >= 2.7.0, < 3.3.0
kokaki@ESPRIMO:/var/lib/redmine$ vi Gemfile
ruby '>= 2.7.0', '< 3.3.0' → ruby '>= 2.7.0', '< 3.3.1'
kokaki@skynew:/var/lib/redmine$ sudo bundle install --without development test
:
:
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.
・セッション改ざん防止用秘密鍵の作成
kokaki@skynew:/var/lib/redmine$ touch /var/lib/redmine/config/initializers/secret_token.rb
kokaki@skynew:/var/lib/redmine$ sudo -u www-data bin/rake generate_secret_token
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/message_verifier.rb:3:
warning: base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add base64 to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add base64 into its gemspec.
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:
warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add bigdecimal to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add bigdecimal into its gemspec.
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:
warning: mutex_m was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add mutex_m to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add mutex_m into its gemspec.
・データベースのテーブル作成
kokaki@ESPRIMO:/var/lib/redmine$ sudo chown -R www-data /var/lib/redmine
kokaki@ESPRIMO:/var/lib/redmine$ sudo -u www-data RAILS_ENV=production bin/rake db:migrate
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/message_verifier.rb:3:
warning: base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add base64 to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add base64 into its gemspec.
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:
warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add bigdecimal to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add bigdecimal into its gemspec.
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332:
warning: mutex_m was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add mutex_m to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add mutex_m into its gemspec.
■Passengerのインストール
kokaki@skynew:/var/lib/redmine$ sudo gem install passenger -N
Fetching passenger-6.0.20.gem
Building native extensions. This could take a while...
Successfully installed passenger-6.0.20
1 gem installed
A new release of RubyGems is available: 3.5.3 → 3.5.6!
Run `gem update --system 3.5.6` to update your installation.
kokaki@skynew:/var/lib/redmine$ sudo gem update --system 3.5.6
・PassengerのApache用モジュールのインストール
kokaki@skynew:/var/lib/redmine$ sudo apt install -y apache2-dev libapr1-dev libaprutil1-dev
kokaki@skynew:/var/lib/redmine$ sudo passenger-install-apache2-module --auto --languages ruby
・Apache用設定内容の確認
kokaki@skynew:/var/lib/redmine$ sudo passenger-install-apache2-module --snippet
LoadModule passenger_module /usr/local/lib/ruby/gems/3.3.0/gems/passenger-6.0.20/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/lib/ruby/gems/3.3.0/gems/passenger-6.0.20
PassengerDefaultRuby /usr/local/bin/ruby
</IfModule>
・Apacheの設定
kokaki@skynew:/var/lib/redmine$ sudo vi /etc/apache2/conf-available/redmine.conf
# Redmineの画像ファイル・CSSファイル等へのアクセスを許可する設定。
# Apache 2.4のデフォルトではサーバ上の全ファイルへのアクセスが禁止されている。
<Directory "/var/lib/redmine/public">
Require all granted
</Directory>
# Passengerの基本設定。
# passenger-install-apache2-module --snippet で表示された設定を記述。
# 環境によって設定値が異なるため以下の5行はそのまま転記せず、必ず
# passenger-install-apache2-module --snippet で表示されたものを使用すること。
#
LoadModule passenger_module /usr/local/lib/ruby/gems/3.3.0/gems/passenger-6.0.20/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/lib/ruby/gems/3.3.0/gems/passenger-6.0.20
PassengerDefaultRuby /usr/local/bin/ruby
</IfModule>
# 必要に応じてPassengerのチューニングのための設定を追加(任意)。
# 詳しくは Configuration reference - Passenger + Apache
# (https://www.phusionpassenger.com/docs/references/config_reference/apache/) 参照。
PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 864000
PassengerStatThrottleRate 10
# Redmineのインストールディレクトリへのアクセスを許可
<Directory /var/lib/redmine/public>
Allow from all
Options -MultiViews
Require all granted
</Directory>
# パターン1
# sudo vi /etc/apache2/sites-enabled/000-default.confを以下のように変更
# 「
# DocumentRoot /var/www/html
# ↓
# DocumentRoot /var/lib/redmine/public
# 」
# パターン2
Alias /redmine /var/lib/redmine/public
<Location /redmine>
PassengerBaseURI /redmine
PassengerAppRoot /var/lib/redmine
</Location>
・Apacheの設定の反映
kokaki@skynew:/var/lib/redmine$ sudo a2enconf redmine
kokaki@skynew:/var/lib/redmine$ apache2ctl configtest
kokaki@skynew:/var/lib/redmine$ sudo systemctl reload apache2
kokaki@skynew:/var/lib/redmine$ sudo EDITOR="mate --wait" bin/rails credentials:edit
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/message_encryptor.rb:4: warning:
base64 was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add base64 to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add base64 into its
gemspec.
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332: warning:
bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby
3.4.0.
Add bigdecimal to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add bigdecimal into
its
gemspec.
/usr/local/lib/ruby/gems/3.3.0/gems/activesupport-6.1.7.6/lib/active_support/dependencies.rb:332: warning:
mutex_m was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0.
Add mutex_m to your Gemfile or gemspec. Also contact author of activesupport-6.1.7.6 to add mutex_m into its
gemspec.
Adding config/master.key to store the encryption key: cc3d2485f9873ad3137e5e3162a1072b
Save this in a password manager your team can access.
If you lose the key, no one, including you, can access anything encrypted with it.
create config/master.key
Ignoring config/master.key so it won't end up in Git history:
append .gitignore
File encrypted and saved.
kokaki@skynew:/var/lib/redmine$ sudo chown -R www-data /var/lib/redmine
kokaki@skynew:/var/lib/redmine$ sudo systemctl restart apache2
http://localhost/redmine
・ログイン
インストール直後のRedmineには管理者しかいないので管理者でログインします。
・ログイン方法
Redmineにアクセスしてください。認証が必要とRedmineに設定されている場合はログイン画面が既に表示されます。
ログイン画面が表示されていない場合は右上の「ログイン」をクリックしてください。
ログインフォームに「ログインID」「パスワード」を入力してログインしてください。
※Redmineをインストールした直後であればログインID、パスワードともに"admin"でログインできます。
■既存RailsプロジェクトをインストールしたRedmineと同居させる
kokaki@skynew:~$ cd /home/kokaki/www/rails/books/
kokaki@skynew:~/www/rails/books$ sudo bundle install
Don't run Bundler as root. Installing your bundle as root will break this application for all non-root users
on this
machine.
Bundler 2.5.5 is running, but your lockfile was generated with 2.3.14. Installing Bundler 2.3.14 and
restarting
using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.3.14
Installing bundler 2.3.14
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will
break
this
application for all non-root users on this machine.
Your Ruby version is 3.3.0, but your Gemfile specified 3.1.2
kokaki@skynew:~/www/rails/books$ vi Gemfile
ruby "3.1.2" → ruby "3.3.0"
kokaki@skynew:~/www/rails/books$ sudo bundle install
kokaki@skynew:~/www/rails/books$ sudo apt install nodejs -y
・Apache2の定義
kokaki@skynew:/var/lib/redmine$ sudo vi /etc/apache2/conf-available/redmine.conf
以下を追記
Alias /blog /home/kokaki/www/rails/blog/public
<Location /blog>
PassengerBaseURI /blog
PassengerAppRoot /home/kokaki/www/rails/blog
</Location>
Alias /books /home/kokaki/www/rails/books/public
<Location /books>
PassengerBaseURI /books
PassengerAppRoot /home/kokaki/www/rails/books
</Location>
kokaki@skynew:/var/lib/redmine$ sudo systemctl restart apache2
■UbuntuにSubversionをインストールする方法
1.subversionのインストール
$ sudo apt update -y
$ sudo apt install -y apache2 apache2-utils
$ sudo apt install -y subversion subversion-tools libapache2-mod-svn
:
:
/etc/aliases does not exist, creating it.
WARNING: /etc/aliases exists, but does not have a root alias.
Postfix (main.cf) is now set up with a default configuration. If you need to
make changes, edit /etc/postfix/main.cf (and others) as needed. To view
Postfix configuration values, see postconf(1).
After modifying main.cf, be sure to run 'systemctl reload postfix'.
Running newaliases
newaliases: fatal: bad string length 0 < 1: mydomain =
dpkg: error processing package postfix (--configure):
installed postfix package post-installation script subprocess returned error exit status 75
Processing triggers for rsyslog (8.2112.0-2ubuntu2.2) ...
Processing triggers for ufw (0.36.1-4ubuntu0.1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
Errors were encountered while processing:
postfix
E: Sub-process /usr/bin/dpkg returned an error code (1)
kokaki@ESPRIMO:~$ sudo vi /etc/postfix/main.cf
myhostname = ESPRIMO. → myhostname = ESPRIMO.kokaki.jp
2.リポジトリを作成
$ sudo mkdir /opt/svn
$ sudo mkdir /opt/svn/test
$ sudo svnadmin create /opt/svn/test
$ sudo chown -R www-data:www-data /opt/svn/test
3.subversionの定義ファイルを作成
$ sudo vi /etc/apache2/mods-enabled/dav_svn.conf
<Location /svn>
DAV svn
SVNParentPath /opt/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
4.subversionのユーザを登録する
・1人目の場合、オプション-cmのcが必要(createのことかな・・・)
$ sudo htpasswd -cm /etc/apache2/dav_svn.passwd kokaki
New password:
Re-type new password:
Adding password for user kokaki
・2人目以降の場合、オプション-mでよい
$ sudo htpasswd -m /etc/apache2/dav_svn.passwd (ユーザ名)
5.subversionの再起動・有効化
$ sudo systemctl restart apache2
6.ブラウザからのアクセス(動作確認)
http://localhost/svn/test/
ユーザー・パスワードを聞いてくる
7.subversionのバージョン確認方法
$ svn --version
svn, version 1.14.1 (r1886195)
compiled May 21 2022, 10:52:35 on x86_64-pc-linux-gnu
Copyright (C) 2021 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/
The following repository access (RA) modules are available:
* ra_svn : Module for accessing a repository using the svn network protocol.
- with Cyrus SASL authentication
- handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
* ra_serf : Module for accessing a repository via WebDAV protocol using serf.
- using serf 1.3.9 (compiled with 1.3.9)
- handles 'http' scheme
- handles 'https' scheme
The following authentication credential caches are available:
* Gnome Keyring
* GPG-Agent
* KWallet (KDE)