redmine を Ubuntu 20.04 にインストール

古い内容だが、インストール時のメモを残しておく。

言語と地域の設定

sudo locale-gen ja_JP.UTF-8
sudo timedatectl set-timezone Asia/Tokyo

開発環境、Webサーバその他インストール

sudo apt install -y build-essential zlib1g-dev libssl-dev \
 libreadline-dev libyaml-dev libcurl4-openssl-dev libffi-dev
sudo apt install -y mariadb-server libmariadb-dev
sudo apt install -y apache2 apache2-dev
sudo apt install -y imagemagick fonts-takao-pgothic
sudo apt install -y subversion git
sudo apt install -y postfix

ruby をインストール

curl -O https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.gz
tar xvf ruby-2.7.6.tar.gz
cd ruby-2.7.6
./configure --disable-install-doc
make
sudo make install
cd ..

MariaDBでデータベースを生成

sudo mysql
CREATE DATABASE redmine CHARACTER SET utf8mb4; CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost'; \q

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/4.2-stable /var/lib/redmine
sudo cp -p /var/lib/redmine/config/database.yml{.example,}
sudo vi /var/lib/redmine/config/database.yml

database.ymlを以下のように編集

--- /var/lib/redmine/config/database.yml.example        2022-06-14 07:48:44.550006498 +0000+++ /var/lib/redmine/config/database.yml        2022-06-14 07:50:28.124755810 +0000
@@ -6,8 +6,8 @@
   adapter: mysql2
   database: redmine
   host: localhost
-  username: root
-  password: ""
+  username: redmine
+  password: "password"
   # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
   encoding: utf8mb4
sudo cp -p /var/lib/redmine/config/configuration.yml{.example,}
sudo vi /var/lib/redmine/config/configuration.yml

configuration.ymlを以下のように編集

--- /var/lib/redmine/config/configuration.yml.example   2022-06-14 07:48:44.510007084 +0000+++ /var/lib/redmine/config/configuration.yml   2022-06-14 07:52:21.095751263 +0000
@@ -227,6 +227,12 @@
 # specific configuration options for production environment
 # that overrides the default ones
 production:
+  email_delivery:
+    delivery_method: :smtp
+    smtp_settings:
+      address: "localhost"
+      port: 25
+      domain: "ubuntu-redmine.example.com"

 # specific configuration options for development environment
 # that overrides the default ones

ruby の bundle install

cd /var/lib/redmine
sudo bundle install --without development test

トークン生成、データベース作成

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

passenger をインストール

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

Apache の設定

passenger-install-apache2-module --snippet
sudo vi /etc/apache2/conf-available/redmine.conf

redmine.confの中身

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

LoadModule passenger_module /usr/local/lib/ruby/gems/2.7.0/gems/passenger-6.0.14/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/lib/ruby/gems/2.7.0/gems/passenger-6.0.14
  PassengerDefaultRuby /usr/local/bin/ruby
</IfModule>

PassengerMaxPoolSize 20
PassengerMaxInstancesPerApp 4
PassengerPoolIdleTime 864000
PassengerStatThrottleRate 10

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

Alias /redmine /var/lib/redmine/public
<Location /redmine>
  PassengerBaseURI /redmine
  PassengerAppRoot /var/lib/redmine
</Location>

apacheの設定を読み込む

sudo a2enmod ssl
sudo a2ensite default-ssl
sudo a2enconf redmine
sudo apache2ctl configtest
sudo systemctl reload apache2