0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu 22.04 LTSにRedmine 5.0をインストール

Posted at

RedmineはVPSのテンプレで簡単にインストールできるような便利な時代になりました。
そんな時代ですが「手動でインストールしてみるのも勉強だ」ということで、Ubuntu 22.04 LTSにRedmine 5.0をインストールしてみようと思います。

パッケージのインストール

まずはひたすらインストールを行っていきます。

sudo apt update
sudo apt install -y build-essential zlib1g-dev libssl-dev libreadline-dev libyaml-dev libcurl4-openssl-dev libffi-dev
sudo apt install -y postgresql libpq-dev
sudo apt install -y apache2 apache2-dev
sudo apt install -y imagemagick fonts-takao-pgothic
sudo apt install -y subversion git

Rubyのインストール

続いては、Rubyのインストールに移ります。

curl -O https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.gz

上記ダウンロード下ファイルを解凍し、以下のコマンドを順番に入れていきます。

tar xvf ruby-3.1.2.tar.gz
cd ruby-3.1.2
./configure --disable-install-doc
make
sudo make install
cd ..

問題なく進めているはずですが、念のため確認しまs

ruby -v

どうやら無事に成功しているようです。

インストールが成功している時の表示
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

PostgreSQLの設定

ユーザーを作成します。

sudo -i -u postgres createuser -P redmine

任意のパスワードを入力してから、Redmine用のデータベースを作成。

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

Redmineのインストール

次はRedmineのインストールです。

次のコマンドを順番に入力していきます。

sudo mkdir /var/lib/redmine
sudo chown www-data /var/lib/redmine
sudo -u www-data svn co https://svn.redmine.org/redmine/branches/5.0-stable /var/lib/redmine

viエディタでRedmineからデータベースへ接続するのに必要なファイルを作成。

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

database.ymlに以下の内容を入力&保存。

production:
adapter: postgresql
database: redmine
host: localhost
username: redmine
password: "任意のパスワード"
encoding: utf8

次はメールサーバへの接続に必要な設定ファイルを作成するので、Redmineをインストールしたフォルダの直下に移動し、以下を入力。

vi config/configuration.yml

作成されたconfiguration.ymlに以下をコピペ&保存。

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

rmagick_font_path: /usr/share/fonts/truetype/takao-gothic/TakaoPGothic.ttf

ディレクトリを移動して、

cd /var/lib/redmine

ここでrubyに必要なgemパッケージをインストール。

sudo bundle install --without development test

Redmine動作関連の設定

セッション改ざん防止用の秘密鍵を作成

sudo -u www-data bin/rake generate_secret_token

config/database.yml で指定したデータベースにテーブルを作成

sudo -u www-data RAILS_ENV=production bin/rake db:migrate

Apache上でRedmineを実行するのに必要なPhusion Passengerをインストール。

sudo gem install passenger -N

PassengerのApache用モジュールをインストール。

sudo passenger-install-apache2-module --auto --languages ruby

Passengerの基本設定を以下のコマンドで確認。
※後で必要になるので、コピペしておく。

passenger-install-apache2-module --snippet
表示された基本設定
LoadModule passenger_module /usr/local/lib/ruby/gems/3.1.0/gems/passenger-6.0.18/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/lib/ruby/gems/3.1.0/gems/passenger-6.0.18
  PassengerDefaultRuby /usr/local/bin/ruby
</IfModule>

Apacheの設定

Apache用のconfigファイルを作成。

vi /etc/apache2/conf-available/redmine.conf

redmine.confが作成されたら、以下を適宜編集してコピペ。

# Redmineの画像ファイル・CSSファイル等へのアクセスを許可する設定。
# Apache 2.4のデフォルトではサーバ上の全ファイルへのアクセスが禁止されている。
<Directory "/var/lib/redmine/public">
  Require all granted
</Directory>

# Passengerの基本設定。この部分を前項で確認した内容を張り付ける
LoadModule passenger_module /usr/local/lib/ruby/gems/3.1.0/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/lib/ruby/gems/3.1.0/gems/passenger-6.0.14
  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>

Apache起動時に/etc/apache2/conf-available/redmine.conf が読み込まれるようにしたうえで、起動中のApacheに設定内容を反映させます。

sudo a2enconf redmine
apache2ctl configtest
sudo systemctl reload apache2

Apache上のPassengerでRedmineを実行させる設定

configファイルを開きます。

vi /etc/apache2/sites-enabled/000-default.conf

以下の様に編集します。

変更前DocumentRoot /var/www/html
変更後DocumentRoot /var/lib/redmine/public

Apacheを再起動。

apache2ctl configtest
sudo systemctl reload apache2

これでインストール完了です。

作成したRedmineにログイン

以下のURLにアクセスすることでインストールしたRedmineのログイン画面に移動できます。

http://サーバーのIPアドレスまたはホスト名/

なお、初回ログイン時はログインIDもパスワードも「admin」で設定されているため、ログイン後にパスワードやアカウントの初期設定などの変更を行いましょう。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?