接續上次建立好容器並安裝常用的套件後,我們緊接著來安裝Redmine吧
【步驟1】:下載Redmine檔案到tmp資料夾
cd /tmp
wget https://redmine.org/releases/redmine-6.0.3.tar.gz
【步驟2】:解壓縮Redmine到opt資料夾內
cd /opt
tar -xvzf /tmp/redmine-6.0.3.tar.gz
【步驟3】:建立符號連結(symbolic link)
ln -s redmine-6.0.3 redmine
【步驟4】:將www-data改變為/opt/redmine底下的擁有者。通常這麼做是因為網頁伺服器 (如 Apache 或 Nginx) 預設在 Ubuntu/Debian 系統中使用 www-data 這個使用者和群組來讀寫檔案,確保 web 應用程式有正確的讀寫權限
chown -R www-data:www-data /opt/redmine
【步驟5】:複製database範例檔
cd /opt/redmine/config
cp database.yml.example database.yml
【步驟6】:調整DB連線資訊,設定檔很貼心地將所有連線方式都附在裡面,將預設MySQL連線方式全部註解後,打開Sql server註解,並輸入對應的連線資訊
(指令執行後,輸入"a"切換到 插入模式 (Insert mode),才能對文件內的資料作調整,調整後按下"esc",輸入":wq"儲存離開)
vim database.yml
a
咚咚咚(輸入)
esc(按鍵)
:wq
【步驟7】:複製Redmine範例檔,回到redmine資料夾
cp configuration.yml.example configuration.yml
cd ..
【步驟8】:安裝bundler 工具
gem install bundler
套件簡易說明:
● bundler:用於管理專案所需的 gem 依賴關係,並確保整個應用程式使用一致的 gem 版本。
【步驟9】:設定bundle 本地端 (local) 組態,指定在安裝 gem 時要 跳過(不安裝)development 與 test 這兩個群組裡的 gem
bundle config set --local without 'development test'
【步驟10】:根據 Gemfile(和 Gemfile.lock)下載並安裝此專案所需的所有 gem
(須在含有 Gemfile 的專案目錄裡運行)
bundle install
【步驟11】:執行安裝時出現tiny_tds、 psych (5.2.3)、tiny_tds (2.1.7)錯誤,則安裝缺少的套件後再次執行bundle install即可。
gem install tiny_tds #tiny_tds
apt-get install libyaml-dev #psych (5.2.3)
apt-get install freetds-dev #tiny_tds (2.1.7)
【步驟12】:產生一個隨機密鑰,Rails 會使用該密鑰對儲存會話資料的 cookie 進行編碼,從而防止其被竄改。
bundle exec rake generate_secret_token
【步驟13】:設定Rails 以「生產環境 (production)」的設定來執行,並載入 Redmine 的「預設資料」,包含預設的專案分類、工作流程、角色、追蹤器、工作狀態、系統設定等。
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data REDMINE_LANG=zh-TW
指令簡易說明
● rake db:migrate:執行 Rails 的資料庫遷移 (migrations) 工作;它會檢查所有尚未執行的 migration 檔,並依序更新資料庫結構,使之符合最新的應用程式需求。
【步驟14】:停用(disable)指定的虛擬主機 (Virtual Host) 設定檔
a2dissite 000-default.conf
【步驟15】:新增redmine.conf各項參數
vim /etc/apache2/sites-enabled/redmine.conf
<VirtualHost *:80>
ServerName redmine.example.com
RailsEnv production
DocumentRoot /opt/redmine/public
PassengerStickySessions on
PassengerFriendlyErrorPages on
<Directory "/opt/redmine/public">
Allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/redmine_error.log
CustomLog ${APACHE_LOG_DIR}/redmine_access.log combined
</VirtualHost>
【步驟16】:執行Redmine,並在電腦上執行http://127.0.0.1:8080/,出現redmine代表架設成功
/etc/init.d/apache2 start
登入Redmine確認功能(預設帳密admin/admin),第一次登入會要求改密碼,套用後出現Internal Error錯誤
開啟cmd連接至redmine終端機上,實時顯示log
docker exec -i -t <containerID> bash
tail -f /var/log/apache2/error.log
chown -R www-data:www-data /opt
/etc/init.d/apache2 restart
此篇指令
cd /tmp
wget https://redmine.org/releases/redmine-6.0.3.tar.gz
cd /opt
tar -xvzf /tmp/redmine-6.0.3.tar.gz
ln -s redmine-6.0.3 redmine
chown -R www-data:www-data /opt/redmine
cd /opt/redmine/config
cp database.yml.example database.yml
vim database.yml
cp configuration.yml.example configuration.yml
cd ..
gem install bundler
bundle config set --local without 'development test'
bundle install
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data REDMINE_LANG=zh-TW
a2dissite 000-default.conf
vim /etc/apache2/sites-enabled/redmine.conf
/etc/init.d/apache2 start
參考資料:
https://blog.longwin.com.tw/2025/01/linux-ubuntu-redmine-install-docker-2025/amp/
https://redmine.dev.org.tw/projects/redmine/wiki/redmineinstall
https://www.redmine.org/projects/redmine/wiki/Download
https://github.com/rails-sqlserver/tiny_tds#using-miniportile