LoginSignup
0
0

RockyLinux 9 へ Redmine 5.0.7 をインストールする

Posted at

はじめに

RockyLinux 9 へ Redmine をインストールしようとしてネットで調べたり ChatGPT に聞いてみたりしましたが、脳死で実行してもうまくいった事例が見当たらなかったので備忘として記載します。
突っ込みどころが多いですがご容赦ください。

事前準備

1コア&メモリ1GBだと Passenger をインストールする箇所で CPUとメモリが高負荷な状態となりインストール処理が進まなくなったように見える事例がありました。
ほかの方も低いスペックでインストール作業をしていたところ同じところで進まなくなった記事を上げておられましたが、下記のスペックだとうまくいったのでご参考頂ければと思います。

インストール環境
    CPU: 4コア
    MEM: 4GB
    HDD: 8GB
    OS : RockyLinux9

また、OSインストール、SELinux無効化、Firewalld停止/無効化、dnf update は端折りますので各自で実施をお願いします。

パッケージインストール

必要なパッケージをインストールします。

# dnf groupinstall "Development Tools"
# dnf install openssl-devel readline-devel zlib-devel curl-devel libffi-devel postgresql-server postgresql-devel httpd httpd-devel wget subversion git ruby ruby-devel
# dnf install --enablerepo=crb libyaml-devel
# dnf install epel-release
# dnf install ImageMagick ImageMagick-devel

UTF8 インストール
# dnf install glibc-langpack-ja

UTF8 適用
# localectl set-locale LANG=ja_JP.utf8

# localectl set-locale LANG=ja_JP.utf8
# 

UTF8 適用確認
# localectl

# localectl
System Locale: LANG=ja_JP.utf8
    VC Keymap: jp
   X11 Layout: jp
# 

フォントインストール

# wget https://launchpad.net/takao-fonts/trunk/15.03/+download/TakaoFonts_00303.01.zip
# unzip TakaoFonts_00303.01.zip
# mkdir -vp /usr/share/fonts/TakaoFonts
# mv TakaoFonts_00303.01/Takao* /usr/share/fonts/TakaoFonts/

PostgreSQL 初期セットアップ・サービス起動

PostgreSQL 初期セットアップ
# postgresql-setup initdb

# postgresql-setup initdb
WARNING: using obsoleted argument syntax, try --help
WARNING: arguments transformed to: postgresql-setup --initdb --unit postgresql
 * Initializing database in '/var/lib/pgsql/data'
 * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
# 

接続設定
host redmine redmine 127.0.0.1/32 md5 の追記をお願いします
# vi /var/lib/pgsql/data/pg_hba.conf

# IPv4 local connections:
host    redmine         redmine         127.0.0.1/32            md5
host    all             all             127.0.0.1/32            ident

PostgreSQL 起動・自動起動有効化・起動確認
# systemctl start postgresql
# systemctl enable postgresql
# systemctl status postgresql

ロール作成
# sudo -i -u postgres createuser -P redmine

パスワード入力を求められるので、入力したパスワードは忘れないようにしてください

# sudo -i -u postgres createuser -P redmine
Enter password for new role:
Enter it again:
# 

# sudo -i -u postgres createdb -E UTF-8 -l ja_JP.UTF-8 -O redmine -T template0 redmine

# sudo -i -u postgres createdb -E UTF-8 -l ja_JP.UTF-8 -O redmine -T template0 redmine
#

Redmine インストール

インストールディレクトリ作成・オーナー変更・カレントディレクトリ移動
# mkdir -vp /var/lib/redmine
# cd /var/lib/
# chown apache redmine
# cd redmine

Redmine インストール
# sudo -u apache svn co https://svn.redmine.org/redmine/branches/5.0-stable /var/lib/redmine

# sudo -u apache svn co https://svn.redmine.org/redmine/branches/5.0-stable /var/lib/redmine
A    .github
A    app
A    app/controllers
A    app/controllers/issues_controller.rb
A    app/controllers/members_controller.rb
A    app/controllers/news_controller.rb

中略

A    test/unit/workflow_transition_test.rb
A    tmp/test/empty
A    tmp/thumbnails/empty
A    yarn.lock
 U   .
Checked out revision 22595.
#

DB接続設定
password: "パスワード" の部分はロール作成時に入力したパスワードに置換をお願いします。

# vi /var/lib/redmine/config/database.yml

production:
   adapter: postgresql
   databse: redmine
   host: 127.0.0.1
   username: redmine
   password: "パスワード"
   encording: utf8

メール送信設定
# vi /var/lib/redmine/config/configuration.yml

production:
   email_delivery:
      delivery_method: smtp
      smtp_settings:
         address: "localhost"
         port: 25
         domain: "example.com"

   rmagick_font_path: /usr/share/fonts/TakaoFonts/TakaoGothic.ttf

bundler、gem インストール

Bundler インストール
# gem install bundler

# gem install bundler
Fetching bundler-2.5.4.gem
Successfully installed bundler-2.5.4
Parsing documentation for bundler-2.5.4
Installing ri documentation for bundler-2.5.4
Done installing documentation for bundler after 0 seconds
1 gem installed
#

gem インストール
# bundle install --without development test

# 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.
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching rake 13.1.0
Installing rake 13.1.0
Fetching concurrent-ruby 1.2.2
Fetching minitest 5.20.0

中略

Fetching rails 6.1.7.6
Installing rails 6.1.7.6
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.
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 generate_secret_token
# 

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

# RAILS_ENV=production bundle exec rake db:migrate
== 1 Setup: migrating =========================================================
-- create_table("attachments", {:force=>true, :id=>:integer})
   -> 0.0286s
-- create_table("auth_sources", {:force=>true, :id=>:integer})

中略

== 20211213122102 RemoveOpenIdSetting: migrated (0.0015s) =====================

== 20220224194639 DeleteOrphanedTimeEntryActivities: migrating ================
== 20220224194639 DeleteOrphanedTimeEntryActivities: migrated (0.0113s) =======

#

Passenger インストール

# gem install passenger -N

# gem install passenger -N
Fetching rake-13.1.0.gem
Successfully installed rake-13.1.0
Fetching rack-3.0.8.gem
Successfully installed rack-3.0.8
Fetching passenger-6.0.19.gem
Building native extensions. This could take a while...
Successfully installed passenger-6.0.19
3 gems installed
#

下記コマンドで CPU とメモリがインストール処理に専有されるため、処理が途中で進まなくなった場合はスペックを見直していただくようお願いします。
# passenger-install-apache2-module --auto --languages ruby

# passenger-install-apache2-module --auto --languages ruby
Welcome to the Phusion Passenger Apache 2 module installer, v6.0.19.

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:

中略

   installer printed earlier, into one of your Apache configuration files, such
   as /etc/httpd/conf/httpd.conf.


Detected 0 error(s), 3 warning(s).
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 PhusionR (www.phusion.nl) :-)
https://www.phusionpassenger.com

PassengerR is a registered trademark of Phusion Holding B.V.
#

ここまで実行完了したら CPU とメモリは 1コア/1GB 程度まで落としていただいて大丈夫です。

Apache 設定確認

# passenger-install-apache2-module --snippet

# passenger-install-apache2-module --snippet
LoadModule passenger_module /usr/local/share/gems/gems/passenger-6.0.19/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/share/gems/gems/passenger-6.0.19
  PassengerDefaultRuby /usr/bin/ruby
</IfModule>
#

コマンドの実行結果を控えておいてください。

Apache 設定

カレントディレクトリ移動
# cd /etc/httpd/conf.d

Redmine 設定記載
Apache設定に置換 の部分は passenger-install-apache2-module --snippet の実行結果に置換をお願いします。
# vi redmine.conf

<Directory "/var/lib/redmine/public">
   Require all granted
</Directory>

Apache設定に置換

PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 864000
PassengerStatThrottleRate 10

<Directory /var/lib/redmine/public>
   Allow from all
   Options -MultiViews
   Require all granted
</Directory>

# vi /etc/httpd/conf/httpd.conf

既存の DocumentRoot はコメントアウトし、/var/lib/redmine/public の行を追記していただくようお願いします。

#DocumentRoot "/var/www/html"
DocumentRoot "/var/lib/redmine/public"

設定ファイル構文チェック
# httpd -t

# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxx. Set the 'ServerName' directive globally to suppress this message
Syntax OK
#

エラーについては個別にご確認をお願いします。

# systemctl start httpd
# systemctl enable httpd

#起動確認
http://IPアドレス/ へアクセス

image.png

上記の画面が表示されていれば Redmine を利用できる形になっていると思います。お疲れさまでした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0