專案

一般

配置概況

Redmine Installation

Ruby on Rails 5 以後,puma 替代了 webrick 作為開發預設的 HTTP Server,從 Docker Hub 中較新的官方映像檔裡也可以看到 Redmine 應用的啟動已經不再使用 apache2 + Phusion Passenger + webrick 的組合,這對於管理員在安裝或維運一個 Redmine 的環境會簡易許多。

測試環境

  • Rocky Linux 8.8
  • Redmine 5.0.6
  • Ruby 3.0
  • MySQL 8

安裝步驟

1. 關閉 SeLinux

[root@redmine ~]# setenforce 0
[root@redmine ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

2. 防火牆允入

[root@redmine ~]# firewall-cmd --permanent --add-port=3000/tcp
[root@redmine ~]# firewall-cmd --reload

3. 安裝 MySQL 資料庫

[root@redmine ~]# dnf install mysql-server
[root@redmine ~]# systemctl enable mysqld --now

4. MySQL 配置

[root@redmine ~]# mysql_secure_installation
y
0(密碼強度)
YourMySQLrootPassword
YourMySQLrootPassword
y(是否確認使用上面輸入的密碼)
y(是否移除匿名用戶)
y(是否禁止root遠端連線資料庫)
y(是否刪除測試資料庫)
y(是否載入上述的新規則)

5. 建立 Redmine 資料庫與用戶
此處輸入上一步你所自訂的 YourMySQLrootPassword 密碼登入 MySQL

[root@redmine ~]# mysql -u root -p

Mysql> CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmineDBpassword';
Mysql> CREATE DATABASE redmine CHARACTER SET utf8mb4;
Mysql> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
Mysql> FLUSH PRIVILEGES;
Mysql> exit

6. 安裝 Ruby

[root@redmine ~]# dnf module list ruby
Last metadata expiration check: 0:10:27 ago on Mon 13 Nov 2023 06:10:50 PM CST.
Rocky Linux 8 - AppStream
Name              Stream               Profiles                Summary                                                          
ruby              2.5 [d]              common [d]              An interpreter of object-oriented scripting language             
ruby              2.6                  common [d]              An interpreter of object-oriented scripting language             
ruby              2.7                  common [d]              An interpreter of object-oriented scripting language             
ruby              3.0                  common [d]              An interpreter of object-oriented scripting language             
ruby              3.1                  common [d]              An interpreter of object-oriented scripting language

[root@redmine ~]# dnf module reset ruby
[root@redmine ~]# dnf module enable ruby:3.0
[root@redmine ~]# dnf install ruby ruby-devel -y
[root@redmine ~]# ruby -v
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]

7. 安裝相關依賴套件
安裝 ImageMagick、ImageMagick-devel、ghostscript 這三個套件是為了讓 redmine 支援 ImageMagick 相關功能

[root@redmine ~]# dnf install rpm-build wget libxml2-devel make automake libtool mysql-devel openssl-devel libcurl-devel gcc gcc-c++
[root@redmine ~]# dnf install \
    https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm \
    https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-8.noarch.rpm
[root@redmine ~]# dnf install ImageMagick ImageMagick-devel ghostscript

8. 下載與設定 Redmine
redmine.org 下載 所需版本

[root@redmine ~]# mkdir -p /var/www
[root@redmine ~]# cd /var/www
[root@redmine www]# wget https://www.redmine.org/releases/redmine-5.0.6.tar.gz
[root@redmine www]# tar zxvf redmine-5.0.6.tar.gz
[root@redmine www]# mv redmine-5.0.6 /var/www/redmine
[root@redmine www]#  /var/www/redmine
[root@redmine redmine]# cp config/configuration.yml.example config/configuration.yml
[root@redmine redmine]# cp config/database.yml.example config/database.yml
[root@redmine redmine]# nano config/database.yml
production:
  adapter: mysql2
  database: redmine
  host: localhost
  username: redmine
  password: "redmineDBpassword"
  encoding: utf8mb4

9. Redmine 目錄與相關權限設定

[root@redmine redmine]# mkdir -p tmp/pdf
[root@redmine redmine]# chmod -R 755 files log tmp public/plugin_assets

10. 依賴管理安裝與資料庫搬遷

[root@redmine redmine]# nano Gemfile
source 'https://rubygems.org'

ruby '>= 2.5.0', '< 3.2.0'
gem 'bundler', '>= 1.12.0'

gem 'rails', '6.1.7.6'
gem 'puma', (Gem.ruby_version < Gem::Version.new('2.7') ? '< 6.0.0' : '>= 0')
# rails下插入一行 puma 作為稍後要使用的 HTTP 伺服器
[root@redmine redmine]# gem install bundler
[root@redmine redmine]# bundle config set --local without 'development test'
[root@redmine redmine]# bundle install
[root@redmine redmine]# bundle exec rake generate_secret_token
[root@redmine redmine]# RAILS_ENV=production bundle exec rake db:migrate
[root@redmine redmine]# RAILS_ENV=production REDMINE_LANG=en bundle exec rake redmine:load_default_data

11. 啟動 Redmine

[root@redmine redmine]# bundle exec rails server -e production &
[root@redmine redmine]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      629/sshd            
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      2814/puma 6.4.0 (tc 
tcp6       0      0 :::3306                 :::*                    LISTEN      723/mysqld
  • 瀏覽器網址列中輸入 http://hostIP:3000
  • 預設登入帳密為:admin/admin

參考資料

回到頁首