X

於 Ubuntu Linux 22.04 手動安裝 Redmine 5.1

於 Debian Linux 使用 APT 直接安裝 Redmine,遇到的問題太難解了,所以乾脆下載 Redmine 原始碼全部手動安裝~

找到的文章是在 Ubuntu 22.04 + Redmine 5.0.1 的安裝版本,不過實際安裝跟文章寫的還是差距有點大,補上自己的筆記紀錄~

  • 註:此篇安裝的環境使用 Docker 來安裝,方便裝壞隨時打掉重練.. XD

於 Ubuntu Linux 22.04 手動安裝 Redmine 5.1

  1. docker run -p 8080:80 -itd ubuntu:22.04 # 把外部 8080 port 指定到內部 80 port
  2. docker ps # 找到最前面的 Container ID (653xxxxx)
  3. docker exec -it 653 bash
  4. apt-get update && apt-get upgrade -y # 套件先升級到最新版
  5. apt install -y less vim wget net-tools # 常用套件裝一裝 (netstats 在 net-tools 套件內)
  6. apt install -y apache2 ruby ruby-dev build-essential libapache2-mod-passenger libmysqlclient-dev nginx
    1. apt install -y nginx nginx-extras ruby ruby-dev build-essential libmysqlclient-dev libcurl4-openssl-dev
    2. gem install passenger
    3. passenger-install-nginx-module # 選 Ruby (default)、選1 都用預設設定
    4. /usr/bin/nginx -> /opt/nginx/sbin/nginx
      # /opt/nginx/conf/nginx.conf
      http {
         ...
         passenger_root /var/lib/gems/3.0.0/gems/passenger-6.0.23;
         passenger_ruby /usr/bin/ruby3.0;
         ...
      }
  7. apt install -y mysql-server
  8. cd /tmp
  9. wget https://redmine.org/releases/redmine-5.1.3.tar.gz # 直接安裝目前最新版
  10. cd /opt # 將 Redmine 安裝在 /opt/redmine
  11. tar -xvzf /tmp/redmine-5.1.3.tar.gz
  12. ln -s redmine-5.1.3 redmine
  13. chown -R www-data:www-data /opt/redmine
  14. /etc/init.d/mysql start # 啟動 MySQL
  15. mysql -u root
  16. mysql>
    • CREATE DATABASE redmine CHARACTER SET utf8mb4;
    • CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'secretPassword';
    • GRANT ALL PRIVILEGES ON redmine. TO 'redmine'@'localhost';
    • FLUSH PRIVILEGES;
  17. 若遇到密碼錯誤,就用 MySQL 舊版存密碼方式:
    • ALTER USER 'redmine'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secretPassword';
    • FLUSH PRIVILEGES;
  18. cd /opt/redmine
  19. cp configuration.yml.example configuration.yml
  20. cp config/database.yml.example config/database.yml
  21. vim config/database.yml # production、development 都換成下述: (username, password)
    • production:
    •   adapter: mysql2
    •   database: redmine
    •   host: 127.0.0.1 # localhost 改為 127.0.0.1
    •   username: redmine
    •   password: secretPassword
    •   variables:
    •     transaction_isolation: "READ-COMMITTED"
  22. gem install bundler # 使用 gem 安裝 bundler
  23. vim Gemfile # 缺少 tzinfo-data (版本)、blankslate 套件
    • 把這行
      • gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin]
    • 改成
      • #gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin]
      • gem 'tzinfo-data'
      • gem 'blankslate'
  24. bundle config set --local without 'development test'
  25. bundle install
  26. bundle exec rake generate_secret_token
  27. RAILS_ENV=production bundle exec rake db:migrate
  28. RAILS_ENV=production bundle exec rake redmine:load_default_data
    • zh-TW # 輸入這個
    • # RAILS_ENV=production bundle exec rake redmine:load_default_data REDMINE_LANG=zh-TW
  29. a2dissite 000-default.conf # 先把 Apache 預設設定的移除
  30. 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>
    
  31. /etc/init.d/apache2 start
  32. apt-get install libcurl4-openssl-dev apache2-dev libapr1-dev libaprutil1-dev # 編譯所需要的套件,編譯完成相關資訊如下:
  33. gem install passenger # passenger APT 安裝的版本有 security issue,然後執行起來都會有問題,所以全部自己重新安裝
  34. passenger-install-apache2-module # 手動來的話,Apache module 也需要重新編譯
    • LoadModule passenger_module /var/lib/gems/3.0.0/gems/passenger-6.0.23/buildout/apache2/mod_passenger.so
    • <IfModule mod_passenger.c>
    •   PassengerRoot /var/lib/gems/3.0.0/gems/passenger-6.0.23
    •   PassengerDefaultRuby /usr/bin/ruby3.0
    • </IfModule>
    • /var/lib/gems/3.0.0/gems/passenger-6.0.23/bin/passenger
    • /usr/bin/passenger
    • /etc/apache2/mods-enabled/passenger.load
    •   LoadModule /usr/lib/apache2/modules/mod_passenger.so 換成
    •   LoadModule passenger_module /var/lib/gems/3.0.0/gems/passenger-6.0.23/buildout/apache2/mod_passenger.so
  35. vim /etc/apache2/mods-enabled/passenger.conf # 將原始資料都註解掉,改成下述:
    <IfModule mod_passenger.c>
    PassengerDefaultUser www-data
    PassengerRoot /var/lib/gems/3.0.0/gems/passenger-6.0.23
    PassengerDefaultRuby /usr/bin/ruby3.0
    #PassengerDisableSecurityUpdateCheck on
    #SetEnv PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY 0
    #SetEnv PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY 0
    </IfModule>
    #<IfModule mod_passenger.c>
    #  PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
    #  PassengerDefaultRuby /usr/bin/ruby
    #</IfModule>
  36. vim /etc/apache2/mods-enabled/passenger.load # 註解掉,換成剛 Compile 新的路徑和 mod_passenger.so
    #LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so
    LoadModule passenger_module /var/lib/gems/3.0.0/gems/passenger-6.0.23/buildout/apache2/mod_passenger.so
  37. /etc/init.d/apache2 restart # Apache 重新啟動就可以了

外部 Apache 指定進來

<VirtualHost :80>
    ServerName redmine.example.com
    #ProxyPass / http://localhost:8080/
    ProxyPass / http://redmine.example.com:8080/
</VirtualHost>

預設帳號、密碼

  • default admin / admin

參考文件

Tsung: 對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.
Related Post