# Redmine 環境架設&常用指令&常見問題 --- # 下載 Redmine * [Redmine 官方下載](https://www.redmine.org/projects/redmine/wiki/download) ## Redmine 5 Ruby on rails 版本限制 ### Ruby 支援: * 2.51 * 2.6 * 2.7 * 3.0 * 3.1 ### Rails 指定: * 6.1 ### 資料庫版本: * MySQL 5.5 - 5.7 * PostgreSQL 9.2 or higher * Microsoft SQL Server 2012 or higher * SQLite 3 --- # 初始設定 ## 設定 Rails 環境 (production or development or test) ### 養成好習慣 打開 Ruby Terminal 時就先設定 不然會跑到預設環境去 ``` set RAILS_ENV=production ``` ## database 設定 路徑:(config/database.yml) ### Redmine 在 config 有預設 database.yml example 做參考 ### 這裡以 postgresql 為範例建立 database.yml ``` production: adapter: postgresql database: redmine host: <host> port: <port> username: <your username> password: <your password> encoding: utf8 development: adapter: postgresql database: redmine_development host: <host> port: <port> username: <your username> password: <your password> encoding: utf8 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: adapter: postgresql database: redmine_test host: <host> port: <port> username: <your username> password: <your password> encoding: utf8 ``` ## 產生安全性雜湊碼 ``` bundle exec rake generate_secret_token ``` ## 建立資料庫 ``` bundle exec rake db:create bundle exec rake db:migrate ``` ## 開啟 server ``` rails s ``` ### Redmine 預設管理員帳密為 #### 帳號: admin #### 密碼: admin ※第一次進去時會讓你修改 --- # 插件安裝及移除 ## 安裝插件 ### 1. 將插件放到 plugins 資料夾 ### 2. 設定環境 ``` set RAILS_ENV=production ``` ### 3. 安裝依賴 ``` bundle install ``` ### 4. 資料庫更新 ``` bundle exec rake redmine:plugins:migrate ``` ### 5. 重啟 --- ## 移除插件 ### 1. 設定環境 ``` set RAILS_ENV=production ``` ### 2. 解除安裝套件 ``` bundle exec rake redmine:plugins:migrate NAME=<plugin_name> VERSION=0 ``` ### 3. 把插件從資料夾移除 --- # 插件建立指令 ## 前置作業 ### 設置環境 ``` set RAILS_ENV=production ``` ### 創建插件 ``` bundle exec rails g redmine_plugin <plugin name> ``` --- ## Model 建立 ### 建立 model ``` bundle exec rails g redmine_plugin_model <plugin name> <table name> <column name>:<type>... ``` ### migrate 資料庫 ``` bundle exec rake redmine:plugins:migrate ``` --- ## 建立 controller ``` bundle exec rails g redmine_plugin_controller <plugin name> <controller name> <action> ``` --- # 教學資源 * [官方插件教學範例](https://www.redmine.org/projects/redmine/wiki/plugin_tutorial) --- # 常見問題 ## Q1. tzinfo-data  ### 預設 Gemfile 資料夾內已包含以下段落但還是出錯的情況 ``` gem 'tzinfo-data', platforms: [:mingw, :x64_mingw, :mswin] ``` ### 更改上述 Gemfile 段落為以下段落 ``` gem 'tzinfo-data', '1.2014.5' ``` ### 再到 Terminal 執行資料包更新即可 ``` bundle install ``` --- ## Q2. 在預設 Gemfile 抓不到資料庫的情況下的解決方法  ### 預設 Gemfile 內已有引用 database.yml 的方法但吃不到的情況  ### 將上述段落改成以下段落(依不同 postgresql 版本做調整) ``` gem "pg", "~> 1.1" ``` ### 再到 Terminal 執行資料包更新即可 ``` bundle install ``` --- ## Q3. 執行 rake db:create 失敗原因  ### 可能問題: database.yml 設定有錯 ### 解決方法: 檢查 database.yml 設定 --- ## Q4. 網頁上資料庫連接失敗  ### 可能問題1: database.yml 設定有錯 ### 解決方法: 檢查 database.yml 設定 ### 可能問題2: 在確定 database.yml 設定沒問題的情況下 ### 解決方法: 可能的是因為沒有在 Terminal 設定到 RAILS_ENV=production --- ## Q5. 執行 rake db:create 後 Internal error  ### 可能問題: 沒有執行 db:migrate ### 解決方法: 到終端機執行 db:migrate ``` rake db:migrate ``` --- ## Q6. secret_key_base 問題   ### 可能問題: 未到 Terminal 設定過安全性雜湊碼 ### 解決方法: 到 Terminal 執行以下段落即可 ``` bundle exec rake generate_secret_token ``` --- ## Q7. Rails_ENV=production 環境下的 debug 方式 ### 到 Redmine 資料夾中的(log/production.log)即可得知錯誤訊息 --- ###### tags: `Redmine交付成果`
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.