Amazon Linux 2 に Ruby 3.3 + OpenSSL 3.0 で Redmine 6.0 を構築する
既存の Amazon Linux 2 環境に Redmine 6.0 を構築したときの作業記録です。
標準の Ruby / OpenSSL がいずれも古く、そのままでは Redmine 6.0 が動かないため、OpenSSL 3.0 を自前ビルドし、rbenv で Ruby 3.3.7 を導入しています。
最終的な構成は以下のとおりです。
[ ユーザー ]
│ HTTP / HTTPS(80番,443番)
▼
[ Nginx:リバースプロキシ ]
│ プロキシ転送(127.0.0.1:8080)
▼
[ Apache + Passenger(8080番) ]
│
▼
[ Redmine 6.0 ]
├──→ [ RDS:MySQL 8.0 ](データ保存)
└──→ [ Amazon SES ](メール通知)
| 項目 | 値 |
|---|---|
| OS | Amazon Linux 2(サポート終了: 2026-06-30) |
| Ruby | 3.3.7(rbenv 管理) |
| OpenSSL | 3.0.16(自前ビルド) |
| Web サーバ | Nginx 1.20(フロント) + Apache 2.4 + Passenger 6.0 |
| DB | Amazon RDS (MySQL 8.0) |
| Redmine | 6.0-stable |
| メール | Amazon SES (SMTP) ※オプション |
1. 事前準備
OS バージョン確認
$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
...
PRETTY_NAME="Amazon Linux 2"
SUPPORT_END="2026-06-30"
$ uname -a
Linux ip-xxx-xx-x-xx ... 5.10.233-224.894.amzn2.x86_64 ... x86_64 GNU/Linux
タイムゾーン設定とアップデート
$ sudo su -
# timedatectl set-timezone Asia/Tokyo
# yum update -y
# reboot
Redmine 実行ユーザの作成
Ruby のビルドなども含めて、この redmine ユーザで行います。
# useradd redmine
# passwd redmine
Apache グループに所属させ、ホームディレクトリの所有者・権限も調整します。
# usermod -aG apache redmine
# chown -R redmine:apache /home/redmine
# chmod 750 /home/redmine
2. 必要パッケージのインストール
# yum groupinstall -y "Development Tools"
# yum install -y gcc gcc-c++ make automake autoconf curl wget tar git \
sqlite-devel mariadb-devel libffi-devel ImageMagick ImageMagick-devel
標準提供の Ruby / OpenSSL はバージョンが古く、Redmine 6.0 には使えません。
# yum info ruby
...
Version : 2.0.0.648
...
# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
Ruby 2.0 / OpenSSL 1.0.2 では要件を満たさないため、別途用意していきます。
3. OpenSSL 3.0 のビルド
ビルドに必要な Perl モジュール
# yum install -y perl perl-core perl-App-cpanminus
# cpanm IPC::Cmd
# perl -MIPC::Cmd -e 'print "IPC::Cmd is installed\n";'
IPC::Cmd is installed
ソースからビルド
# cd /usr/local/src
# wget https://www.openssl.org/source/openssl-3.0.16.tar.gz
# tar xzf openssl-3.0.16.tar.gz
# cd openssl-3.0.16/
# ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
Configuring OpenSSL version 3.0.16 for target linux-x86_64
...
*** OpenSSL has been successfully configured ***
# make
# echo $?
0
# make install
インストール結果を確認します。
# ll /usr/local/openssl/
total 40
drwxr-xr-x 2 root root 37 ... bin
drwxr-xr-x 2 root root 6 ... certs
drwxr-xr-x 5 root root 173 ... lib64
...
redmine ユーザに PATH を通す
redmine ユーザの .bashrc に以下を追記し、ビルドした OpenSSL 3.0 を優先して使うようにします。
# su - redmine
$ vi .bashrc
$ tail -2 .bashrc
export LD_LIBRARY_PATH=/usr/local/openssl/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/openssl/bin:$PATH
$ source .bashrc
$ openssl version
OpenSSL 3.0.16 11 Feb 2025 (Library: OpenSSL 3.0.16 11 Feb 2025)
OpenSSL 3.0.16 が見えるようになりました。
4. rbenv + Ruby 3.3.7 のインストール
Ruby ビルド用パッケージ
# yum install -y libyaml-devel
rbenv / ruby-build の導入
# su - redmine
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init - bash)"' >> ~/.bashrc
$ source ~/.bashrc
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Ruby 3.3.7 のインストール
先に通した OpenSSL 3.0 を使って openssl 拡張がビルドされます。
$ rbenv install 3.3.7
==> Downloading ruby-3.3.7.tar.gz...
==> Installing ruby-3.3.7...
-> ./configure "--prefix=$HOME/.rbenv/versions/3.3.7" --enable-shared --with-ext=openssl,psych,+
-> make -j 1
-> make install
==> Installed ruby-3.3.7 to /home/redmine/.rbenv/versions/3.3.7
$ rbenv global 3.3.7
$ ruby -v
ruby 3.3.7 (2025-01-15 revision be31f993d7) [x86_64-linux]
bundler / RubyGems の準備
$ gem install bundler
Successfully installed bundler-2.6.5
$ gem update --system 3.6.5
$ gem -v
3.6.5
$ rbenv rehash
5. Apache + Passenger のインストール
Apache + Passenger で構築します。Passenger は yum のモジュールではなく passenger-install-apache2-module でインストールします。
必要パッケージ
# yum install -y epel-release
# yum install -y httpd httpd-devel
# yum install -y libcurl-devel
swap の作成
passenger-install-apache2-module 実行時、メモリが少ないとエラーになるため一時的に swap を作成します。
# dd if=/dev/zero of=/swap bs=1M count=1024
# mkswap /swap
# swapon /swap
# free -h
total used free shared buff/cache available
Mem: 952M 103M 71M 460K 777M 701M
Swap: 1.0G 0B 1.0G
※
insecure permissions 0644, 0600 suggested.という警告が出ます。気になる場合はchmod 600 /swapしてからmkswap/swaponしてください。
※ 再起動後も使う場合は/etc/fstabへの追記が必要です(本検証では一時利用のみ)。
Passenger gem のインストール
# su - redmine
$ gem install passenger --no-document
Successfully installed passenger-6.0.26
$ passenger -v
Phusion Passenger(R) 6.0.26
Apache モジュールのビルド
基本的にすべて Enter で進めます。
$ passenger-install-apache2-module
途中、以下のような権限警告が出ることがあります。
It is recommended that you relax permissions as follows:
sudo chmod o+x "/home/redmine"
依存チェックがすべて Found: yes となり、最後に Apache へ追記すべき設定が表示されます。
LoadModule passenger_module /home/redmine/.rbenv/versions/3.3.7/lib/ruby/gems/3.3.0/gems/passenger-6.0.26/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/redmine/.rbenv/versions/3.3.7/lib/ruby/gems/3.3.0/gems/passenger-6.0.26
PassengerDefaultRuby /home/redmine/.rbenv/versions/3.3.7/bin/ruby
</IfModule>
Passenger モジュールを Apache に組み込む
# vi /etc/httpd/conf.d/passenger.conf
# cat /etc/httpd/conf.d/passenger.conf
LoadModule passenger_module /home/redmine/.rbenv/versions/3.3.7/lib/ruby/gems/3.3.0/gems/passenger-6.0.26/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /home/redmine/.rbenv/versions/3.3.7/lib/ruby/gems/3.3.0/gems/passenger-6.0.26
PassengerDefaultRuby /home/redmine/.rbenv/versions/3.3.7/bin/ruby
</IfModule>
# systemctl restart httpd
# httpd -M | grep -i passenger
passenger_module (shared)
passenger_module (shared) が表示されれば読み込み成功です。
6. RDS (MySQL) でデータベースを作成
今回はあくまで検証用のため、マスターユーザで Redmine 用 DB に接続する構成にしています。
本番運用では Redmine 専用ユーザを作成し、最小権限を付与することを推奨します。
| 項目 | 値(例) |
|---|---|
| DB 識別子 | redmine-test-db |
| エンドポイント | <RDS_ENDPOINT> |
| マスターユーザー名 | redmine |
| マスターパスワード | <RDS_PASSWORD> |
MySQL クライアントで接続して DB 作成
# yum install mysql
# su - redmine
$ mysql -u redmine -p -h <RDS_ENDPOINT>
Enter password:
...
Server version: 8.0.40 Source distribution
MySQL [(none)]> CREATE DATABASE redmine CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Query OK, 1 row affected (0.02 sec)
MySQL [(none)]> exit
7. Redmine 6.0 の導入
ソース取得と依存 gem のインストール
# su - redmine
$ git clone https://github.com/redmine/redmine.git -b 6.0-stable redmine
$ cd redmine/
$ gem install bundler
$ bundle config set --local path 'vendor/bundle'
$ bundle install --without development test
シークレットトークン生成
$ bundle exec rake generate_secret_token
database.yml の設定
$ cp config/database.yml.example config/database.yml
$ vi config/database.yml
production:
adapter: mysql2
database: redmine
host: <RDS_ENDPOINT>
username: redmine
password: "<RDS_PASSWORD>"
encoding: utf8mb4
variables:
transaction_isolation: "READ-COMMITTED"
マイグレーション(mysql2 gem の追加インストール)
最初の db:migrate で mysql2 gem が無いと怒られました。
$ bundle exec rake db:migrate RAILS_ENV=production
Could not find gem 'mysql2 (~> 0.5.0)' in locally installed gems.
Run `bundle install` to install missing gems.
database.yml を設定したことで mysql2 が依存に含まれるようになったため、再度 bundle install します。
$ bundle install --without development test
...
Installing mysql2 0.5.6 with native extensions
Bundle complete! 43 Gemfile dependencies, 87 gems now installed.
改めてマイグレーションを実行します。
$ bundle exec rake db:migrate RAILS_ENV=production
== 1 Setup: migrating =========================================================
-- create_table("attachments", ...)
...
== 20241103184550 ChangeBuiltinRolesUserVisibility: migrated (0.0279s) ========
デフォルトデータの投入
言語選択では ja を指定します。
$ bundle exec rake redmine:load_default_data RAILS_ENV=production
Select language: ar, az, ... ja, ... [en] ja
====================================
Default configuration data loaded.
Apache の VirtualHost 設定
# vi /etc/httpd/conf.d/redmine.conf
# cat /etc/httpd/conf.d/redmine.conf
<VirtualHost *:80>
ServerName redmine.example.com
DocumentRoot /home/redmine/redmine/public
<Directory /home/redmine/redmine/public>
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
# httpd -t
Syntax OK
# apachectl restart
8. トラブルシュート: stringio のバージョン不一致
この時点ではまだ画面が表示されません。Apache のエラーログ (/var/log/httpd/error_log) を確認します。
App output: Error: The application encountered the following error:
You have already activated stringio 3.1.1, but your Gemfile requires stringio 3.1.5.
(Gem::LoadError)
stringio の default gem が古いことが原因です。新しいバージョンを入れます。
# su - redmine
$ gem list stringio
stringio (default: 3.1.1)
$ gem install stringio -v 3.1.5
Successfully installed stringio-3.1.5
bundle update しようとすると frozen mode で怒られます。
$ cd redmine/
$ bundle update stringio
Bundler is unlocking gems: (stringio), but the lockfile can't be updated because frozen mode is set
Gemfile.lock を削除し、deployment / frozen 設定を解除してから入れ直します。
$ rm Gemfile.lock
$ bundle config --delete deployment
$ bundle config set frozen false
$ bundle install
...
Bundle complete! 43 Gemfile dependencies, 87 gems now installed.
Apache を再起動すると無事表示されました。
$ logout
# apachectl restart
https://redmine.example.com/
初回ログイン後、
adminの初期パスワードは必ず変更してください。
9. Nginx をフロントに置く(リバースプロキシ)
最終的に以下の通信経路にします。
[ ユーザー ]
│ HTTP / HTTPS(80番,443番)
▼
[ Nginx:リバースプロキシ ]
│ プロキシ転送(127.0.0.1:8080)
▼
[ Apache + Passenger(8080番) ]
Apache を 8080 番に変更
VirtualHost をループバックの 8080 番で待ち受けるように変更します。
# vi /etc/httpd/conf.d/redmine.conf
# cat /etc/httpd/conf.d/redmine.conf
<VirtualHost 127.0.0.1:8080>
ServerName redmine.example.com
DocumentRoot /home/redmine/redmine/public
<Directory /home/redmine/redmine/public>
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
httpd.conf の Listen を 80 → 8080 に変更し、あわせてセキュリティヘッダも追加します。
# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
# vi /etc/httpd/conf/httpd.conf
# diff -u /etc/httpd/conf/httpd.conf.org /etc/httpd/conf/httpd.conf
-Listen 80
+Listen 8080
@@ -360,3 +360,12 @@
IncludeOptional conf.d/*.conf
+
+# Security settings
+ServerTokens ProductOnly
+Header always unset "X-Powered-By"
+RequestHeader unset Proxy
+Header always set X-Frame-Options "SAMEORIGIN"
+Header always set X-XSS-Protection "1; mode=block"
+Header always set X-Content-Type-Options "nosniff"
+TraceEnable Off
設定を確認して再起動します。
# httpd -S
VirtualHost configuration:
127.0.0.1:8080 redmine.example.com (/etc/httpd/conf.d/redmine.conf:1)
...
# apachectl restart
# netstat -lntp
tcp6 0 0 :::8080 :::* LISTEN xxx/httpd
Apache が 8080 のみで Listen していることを確認できました。
Nginx のインストールと設定
# yum install nginx
...
nginx.x86_64 1:1.20.1-10.el7
Complete!
# vi /etc/nginx/conf.d/redmine.conf
# cat /etc/nginx/conf.d/redmine.conf
server {
listen 80;
server_name redmine.example.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
# nginx -t
nginx: configuration file /etc/nginx/nginx.conf test is successful
# systemctl enable --now nginx
待ち受けポートを確認します。Nginx が 80番、Apache が 8080番になっていれば OK です。
# netstat -lntp
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN xxx/nginx: master p
tcp6 0 0 :::8080 :::* LISTEN xxx/httpd
https://redmine.example.com/
正常に動作することを確認できました。
10.(オプション)Amazon SES でメール通知
同梱の Postfix でも構いませんが、せっかくなので Amazon SES を使ってみます。
SES の SMTP 設定情報
| 項目 | 値 |
|---|---|
| SMTP エンドポイント | email-smtp.<region>.amazonaws.com |
| TLS | 必須 |
| STARTTLS ポート | 25 / 587 / 2587 |
| TLS ラッパーポート | 465 / 2465 |
| SMTP ユーザー名 | <SES_SMTP_USERNAME> |
| SMTP パスワード | <SES_SMTP_PASSWORD> |
configuration.yml の設定
# su - redmine
$ cd redmine/config/
$ cp configuration.yml.example configuration.yml
$ vi configuration.yml
$ cat configuration.yml
default:
email_delivery:
delivery_method: :smtp
smtp_settings:
address: "email-smtp.<region>.amazonaws.com"
port: 587
domain: "aws.example.com"
authentication: :login
user_name: "<SES_SMTP_USERNAME>"
password: "<SES_SMTP_PASSWORD>"
$ logout
# systemctl restart httpd
Redmine の管理画面から送信元アドレス(例: redmine@aws.example.com)を設定し、テストメールを送信します。無事に送信できました。
SES は無料利用枠(送信通数)に上限があります。検証後にリソースを削除する場合は、SES の認証情報・IAM ユーザもあわせて削除してください。
まとめ
- Amazon Linux 2 の標準 Ruby / OpenSSL は古いため、OpenSSL 3.0 を自前ビルドし、rbenv で Ruby 3.3.7 を入れることで Redmine 6.0 を動かせました。
- Passenger は
passenger-install-apache2-moduleで導入。メモリ不足対策に一時 swap が有効でした。 -
stringioの default gem バージョン不一致は、Gemfile.lockを作り直す(frozen / deployment 解除)ことで解消できました。 - 公開は Nginx をフロントに置いたリバースプロキシ構成にし、Apache はループバックの 8080 番に限定しました。
なお Amazon Linux 2 はサポート終了(2026-06-30)が迫っているため、新規構築であれば Amazon Linux 2023 など後継 OS の利用も検討すると良いでしょう。