跳到主內容

Redmine 開源專案管理 - Debian / Ubuntu

  BUBU 因為看了一本是用 Redmine 專案方式來處理有關於資訊人員在 MIS 上面管理事務記錄,之前有花點時間去架設這一套結果失敗,那後來沒有時間最近剛好想到再重新測試已有架設成功,記錄一下安裝過程。

運行環境


  環境都是在 「Proxmox VE 」 虛擬系統上架設,都是以 「 LXC 」模式為主,除非有特殊狀況會告知使用 「 VM 」 模式

  • 系統環境: Debian 12、Ubuntu 2204
  • Web 服務: Nginx 1.22.1
  • 資料庫服務: MariaDB 10.6、10.11

安裝過程


前置處理

  • 安裝必要套件
apt install build-essential ruby-dev libxslt1-dev libmariadb-dev gnupg2 bison libbison-dev libgdbm-dev libncurses-dev libncurses5-dev libxml2-dev zlib1g-dev imagemagick libmagickwand-dev libreadline-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 -y
  • 建立 Redmine 專用系統帳號
useradd -r -m -d /opt/redmine -s /bin/bash redmine
  • Redmine 新增加到 www-data 群組有權限可以執行
usermod -aG redmine www-data
資料庫

  • 安裝資料庫,用系統所提供資料庫版即可
apt install mariadb-server -y
  • 啟用資料庫服務
sudo systemctl enable --now mariadb
  • 設定管理者密碼
mariadb-secure-installation
  • 設定使用 root 帳號可以免密碼就可以登入修正方式請參考本篇進行修改 MariaDB root 可空白登入

  • 設定 redmin 資料表

CREATE DATABASE redminedb;
GRANT ALL on redminedb.* to redmineuser@localhost identified by 'password';
FLUSH PRIVILEGES;
exit;
安裝 Redmine 服務

  • 下載目前官方最新版本,BUBU 所安裝版本是 5.1.2 版 官方載點
wget https://www.redmine.org/releases/redmine-5.1.2.tar.gz
  • 解壓剛剛下載好的壓縮檔並且放置到 /opt 目錄下
tar -xzvf redmine-5.1.2.tar.gz -C /opt/redmine/ --strip-components=1
  • 設定權限
chown -R redmine: /opt/redmine/
  • 切換帳號到 redmine
su - redmine
  • 複製預設的設定檔
cp -a /opt/redmine/config/configuration.yml{.example,}
cp -a /opt/redmine/config/database.yml{.example,}
cp -a /opt/redmine/public/dispatch.fcgi{.example,}
  • 設定資料庫連線資訊 vim /opt/redmine/config/database.yml 設定完後就存檔離開
production:
  adapter: mysql2
  # 連線資料庫名稱
  database: redminedb
  # 連線資料庫位置
  host: localhost
  # 連線資料庫帳號
  username: redmineuser
  # 連線資料庫密碼
  password: "passwd"
  # Use "utf8" instead of "utfmb4" for MySQL prior to 5.7.7
  encoding: utf8mb4
  variables:
    # Recommended `transaction_isolation` for MySQL to avoid concurrency issues is
    # `READ-COMMITTED`.
    # In case of MySQL lower than 8, the variable name is `tx_isolation`.
    # See https://www.redmine.org/projects/redmine/wiki/MySQL_configuration
    # transaction_isolation: "READ-COMMITTED" <<< 這是預設的參數,上面的說明有說這是 from mysql 8 用,那由於 BUBU 是用 MariaDB 因此需要把這個預設參數註解新增加下面的參數,在執行安裝時候才不會出現錯誤訊息。
    tx_isolation: "READ-COMMITTED"
  • 退出該帳號回到 root 或其他帳號繼續操作

  • 進到 redmine 目錄並且開始安裝服務

cd /opt/redmine && gem install bundler
  • 再次切換到 redmine 帳號操作

  • 開始安裝 redmine 服務

bundle config set --local path 'vendor/bundle'
bundle install
bundle update
  • 建立金鑰及資料庫服務
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
  • 設定預設的資料並且將語系設定為中文
RAILS_ENV=production REDMINE_LANG=zh-TW bundle exec rake redmine:load_default_data
  • 啟動服務測試站台連線
bundle exec rails server -e production
  • 開啟網頁輸入您的站台位置 http://連線位置:3000,正常會出現畫面,確認沒有問題開始安裝 web 服務
安裝 Nginx 服務

  • Nginx 一樣使用系統所提供的來源庫
sudo apt-get install nginx -y
  • 啟動 Nginx 服務
sudo systemctl enable --now nginx
  • 由於 Redmine 是用 Ruby on Rails 該語言所編寫,因此需要外掛套件才能正常運行

    # Install our PGP key and add HTTPS support for APT
    sudo apt-get install -y dirmngr gnupg apt-transport-https ca-certificates curl
    
    curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/phusion.gpg >/dev/null
    
    # Add our APT repository
    sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bookworm main > /etc/apt/sources.list.d/passenger.list'
    sudo apt-get update
    
    # Install Passenger + Nginx module
    sudo apt-get install -y libnginx-mod-http-passenger -y
    
    # Install our PGP key and add HTTPS support for APT
    sudo apt-get install -y dirmngr gnupg apt-transport-https ca-certificates curl
    
    curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/phusion.gpg >/dev/null
    
    # Add our APT repository
    sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger jammy main > /etc/apt/sources.list.d/passenger.list'
    sudo apt-get update
    
    # Install Passenger + Nginx module
    sudo apt-get install -y libnginx-mod-http-passenger -y
    
  • 重啟 Nginx 服務

sudo systemctl restart nginx
  • 新增 Redmine 設定檔 vim /etc/nginx/conf.d/redmine.conf
server {
        listen 80;
        server_name 連線站台名稱;
        rewrite ^(.*)$ https://${server_name}$1 permanent;
}
#
server {
        # 使用 https 和 http/2 協定
        listen 443 ssl http2;
        # 上述的 IPv6 方式
        listen [::]:443 ssl;
        server_name 連線站台名稱;
        #
        root /opt/redmine/public;
        #
        # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
        #
        # SSL 憑證證書路徑
        ssl_certificate /etc/nginx/ssl/fullchain.pem;
        # 私鑰路徑
        ssl_certificate_key /etc/nginx/ssl/privkey.pem;
        # 緩存有效期
        ssl_session_timeout 1d;
        # 緩存憑證類型和大小
        ssl_session_cache shared:SSL:50m;
        #
        # intermediate configuration. tweak to your needs.
        #
        # 使用的加密協定
        ssl_protocols TLSv1.3 TLSv1.2;
        # 加密演算法,越前面的優先級越高
        ssl_ciphers 'TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5';
        # 交握過程使用 Server 的首選加演算法,這裡使用 Client 為首選
        ssl_prefer_server_ciphers on;
        #
        access_log /var/log/nginx/redmine_access.log;
        error_log /var/log/nginx/redmine_error.log;
        #
        passenger_enabled on;
        passenger_min_instances 1;
        client_max_body_size 10m;
}
  • 確認設定檔是否正常,如沒有問題就再次重啟服務
nginx -t && sudo systemctl restart nginx
  • 測試網頁是否可以正常連線,如連線成功會顯示跟下面一樣圖片

補充說明


備註





參考相關網頁