Redmineの導入
Redmineは、プロジェクト管理ソフトウェアであり、作業管理や課題管理に利用される。
Redmineには、Ruby 2.3以上2.6以下と、データベースサーバとしてMySQL 5.5~5.7、MariaDB、PostgreSQL 9.2以上、Microsoft SQL Server 2012以上、SQLite 3のいずれかが必要である。しかし、MySQL 5.6以上とMariaDBには既存の不具合がある。また、SQLite 3はマルチユーザーでの使用はできない。
ここでは、CentOS 8、Apache HTTP Server 2.4.37、Ruby 2.6.6、PostgreSQL 13.0、Redmine 4.1.1という組み合わせで構築する方法を解説する。
目次
SELinuxの無効化
SELinuxを有効のままRedmineを動かす場合は、SELinuxのための設定がいくつも必要となる。いろいろと大変なので、ここでは無効にしておく。
vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
Apache HTTP Serverのインストール
Webサーバ(Apache httpd)の構築を参照に、Apache HTTP Serverをインストールする。
Rubyのインストール
Rubyのインストールを参照して、Ruby 2.6.6をインストールする。
また、Ruby用のパッケージ管理ツールbundlerもインストールする。
gem install bundler
PostgreSQLのインストール
Redmine用データベースの作成
PostgreSQLサーバに接続する。
psql -U postgres -h localhost -p 5432
redmine用ロールを作成する。
CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'my_password' NOINHERIT VALID UNTIL 'infinity';
redmine用データベースを作成する。
CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine;
Redmineに必要なパッケージのインストール
Redmineでは、RMagickを介して、ImageMagickを使用するので、ImageMagickをインストールする。また、日本語フォントもインストールする。
これらのパッケージは、EPELリポジトリからインストールするので、リポジトリの追加を参考に、あらかじめEPELリポジトリを使えるようにしておく。
dnf install ImageMagick ImageMagick-devel libcurl-devel httpd-devel postgresql13-devel rpm-build --enablerepo=PowerTools
Redmineのインストール
Redmineをダウンロードし、展開して、できたフォルダのフォルダパスが/var/lib/redmineになるようにフォルダを移動する。
curl -O https://www.redmine.org/releases/redmine-4.1.1.tar.gz
tar zxvf redmine-4.1.1.tar.gz
mv redmine-4.1.1 /var/lib/redmine
/var/lib/redmineに移動する。
cd /var/lib/redmine
データベース設定ファイルを作成する。
vi config/database.yml
production:
adapter: postgresql
database: redmine
host: localhost
username: redmine
password: "my_password"
encoding: utf8
設定ファイルを作成する。
vi config/configuration.yml
production:
rmagick_font_path: /usr/share/fonts/google-droid/DroidSansJapanese.ttf
bundlerでRedmineの依存パッケージをインストールする。
PostgreSQL13を、インストールしたyumリポジトリからインストールしているので、まず以下でpgインストールに関する設定を行う。
bundle config build.pg --with-pg-config=/usr/pgsql-13/bin/pg_config
依存パッケージのインストールを実施。
bundle install --without development test
秘密鍵を生成する。
bundle exec rake generate_secret_token
テーブルを生成する。
RAILS_ENV=production bundle exec rake db:migrate
データベースにデフォルトのデータを入れる。
RAILS_ENV=production REDMINE_LANG=ja bundle exec rake redmine:load_default_data
RedmineなどのRailsアプリケーションを、Apache HTTP Server上で実行するためのパッケージPassengerをインストールする。
gem install passenger
Apache用モジュールをインストールする。
passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v6.0.6.
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:
1. The Apache 2 module will be installed for you.
2. You'll learn how to configure Apache.
3. You'll learn how to deploy a Ruby on Rails application.
Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.
Press Enter to continue, or Ctrl-C to abort.
--------------------------------------------
Which languages are you interested in?
Use to select.
If the menu doesn't display correctly, press '!'
‣ ⬢ Ruby
⬡ Python
⬡ Node.js
⬡ Meteor
Apache用の設定の内容を確認する。
passenger-install-apache2-module --snippet
LoadModule passenger_module /usr/local/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.6/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.6
PassengerDefaultRuby /usr/local/rbenv/versions/2.6.6/bin/ruby
出力された内容を含め、以下の内容でApacheの設定ファイルに記述する。
vi /etc/httpd/conf.d/redmine.conf
Alias /redmine /var/lib/redmine/public
<Location /redmine>
PassengerBaseURI /redmine
PassengerAppRoot /var/lib/redmine
</Location>
<Directory "/var/lib/redmine/public">
Require all granted
</Directory>
LoadModule passenger_module /usr/local/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.6/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/passenger-6.0.6
PassengerDefaultRuby /usr/local/rbenv/versions/2.6.6/bin/ruby
</IfModule>
/var/lib/redmineの所有グループ、所有ユーザーを変更する。
chown -R apache.apache /var/lib/redmine
Apache HTTP Serverサービスを再起動する。
systemctl restart httpd
以上により、ウェブブラウザからRedmineが使えるようになる。
ウェブブラウザでhttp://<IPアドレス>/redmineにアクセスし、管理ユーザadmin、初期パスワードadminでサインインする。
サインインすると、パスワードの変更を求められるので、変更しておく。
変更後は、管理ユーザで、ユーザを追加したり、プロジェクトを追加したりするなどの設定を行う。