於 Debian Linux 使用 APT 直接安裝 Redmine,遇到的問題太難解了,所以乾脆下載 Redmine 原始碼全部手動安裝~
找到的文章是在 Ubuntu 22.04 + Redmine 5.0.1 的安裝版本,不過實際安裝跟文章寫的還是差距有點大,補上自己的筆記紀錄~
- 註:此篇安裝的環境使用 Docker 來安裝,方便裝壞隨時打掉重練.. XD
於 Ubuntu Linux 22.04 手動安裝 Redmine 5.1
- docker run -p 8080:80 -itd ubuntu:22.04 # 把外部 8080 port 指定到內部 80 port
- docker ps # 找到最前面的 Container ID (653xxxxx)
- docker exec -it 653 bash
- apt-get update && apt-get upgrade -y # 套件先升級到最新版
- apt install -y less vim wget net-tools # 常用套件裝一裝 (netstats 在 net-tools 套件內)
- apt install -y apache2 ruby ruby-dev build-essential libapache2-mod-passenger libmysqlclient-dev nginx
- apt install -y nginx nginx-extras ruby ruby-dev build-essential libmysqlclient-dev libcurl4-openssl-dev
- gem install passenger
- passenger-install-nginx-module # 選 Ruby (default)、選1 都用預設設定
- /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; ... }
- apt install -y mysql-server
- cd /tmp
- wget https://redmine.org/releases/redmine-5.1.3.tar.gz # 直接安裝目前最新版
- cd /opt # 將 Redmine 安裝在 /opt/redmine
- tar -xvzf /tmp/redmine-5.1.3.tar.gz
- ln -s redmine-5.1.3 redmine
- chown -R www-data:www-data /opt/redmine
- /etc/init.d/mysql start # 啟動 MySQL
- mysql -u root
- mysql>
- CREATE DATABASE redmine CHARACTER SET utf8mb4;
- CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'secretPassword';
- GRANT ALL PRIVILEGES ON redmine. TO 'redmine'@'localhost';
- FLUSH PRIVILEGES;
- 若遇到密碼錯誤,就用 MySQL 舊版存密碼方式:
- ALTER USER 'redmine'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secretPassword';
- FLUSH PRIVILEGES;
- cd /opt/redmine
- cp configuration.yml.example configuration.yml
- cp config/database.yml.example config/database.yml
- 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"
- gem install bundler # 使用 gem 安裝 bundler
- 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'
- 把這行
- 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
- zh-TW # 輸入這個
- # RAILS_ENV=production bundle exec rake redmine:load_default_data REDMINE_LANG=zh-TW
- a2dissite 000-default.conf # 先把 Apache 預設設定的移除
- 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>
- /etc/init.d/apache2 start
- apt-get install libcurl4-openssl-dev apache2-dev libapr1-dev libaprutil1-dev # 編譯所需要的套件,編譯完成相關資訊如下:
- gem install passenger # passenger APT 安裝的版本有 security issue,然後執行起來都會有問題,所以全部自己重新安裝
- 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
- 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>
- 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
- /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