動作
如何在 Heroku 上安裝 Redmine (> 2.5.x)¶
好的,經過幾個月的嘗試和失敗,我終於做到了。
因為這是我第一個 Rails 應用程式,我不知道該怎麼做,所以我找了不同的教學。最後,這是我的方法
- http://railsguides.net/2012/04/28/how-to-deploy-redmine-to-heroku/
- http://tygertown.us/redmine-on-heroku/
安裝 Redmine¶
首先,我取得了最新穩定版本的 Redmine(目前為 2.5)
git clone https://github.com/redmine/redmine.git -b 2.5-stable
編輯:使用終端機導航到您的專案
cd redmine
然後,和往常一樣,我們必須從* .gitignore *中刪除這些檔案
Gemfile.lock Gemfile.local public/plugin_assets config/initializers/session_store.rb config/initializers/secret_token.rb config/configuration.yml config/email.yml
因為我一直在資料庫方面遇到問題,所以我直接從* Gemfile *中刪除了整個區塊
database_file = File.join(File.dirname(__FILE__), "config/database.yml")
if File.exist?(database_file)
database_config = YAML::load(ERB.new(IO.read(database_file)).result)
...
else
warn("No adapter found in config/database.yml, please configure it first")
end
else
warn("Please configure your config/database.yml first")
end
並改為在* Gemfile *中添加這個
group :production do
# gems specifically for Heroku go here
gem "pg", ">= 0.11.0"
end
最後安裝 gems。不要被「請先設定您的 config/database.yml」之類的日誌訊息搞混,heroku 會為您處理
bundle install
現在使用以下指令取得密鑰
bundle exec rake generate_secret_token
接下來,您要在 heroku 上建立一個應用程式(我們假設您已經在 heroku 註冊並擁有所有相關的東西)
heroku create NAME_FOR_YOUR_APP為了避免在部署到 heroku 時中止,我們必須執行以下兩個步驟
- 在* config/environment.rb *中,我們必須刪除(或註解掉)第 10 行,其中寫著
exit 1
- 在* config/application.rb *中,我們必須在第 13 行和第 14 行之間添加一行,並添加以下內容:* config.assets.initialize_on_precompile = false *,它應該如下所示
... 12: module RedmineApp 13: class Application < Rails::Application 14: config.assets.initialize_on_precompile = false 15: # Settings in config/environments/* take precedence over those specified here. ...
現在我們終於可以提交我們的變更了
git add -A git commit -m “preparing for heroku” git push heroku 2.5-stable:master
現在只需準備好資料庫,並在出現提示時選擇預設語言
heroku run rake db:migrate heroku run rake redmine:load_default_data
好了,打開您的 redmine 並使用您的憑證登入
heroku open
您的使用者名稱是**admin**,您的密碼也是**admin**。
設定電子郵件¶
首先,您必須將**Sendgrid**附加元件添加到 heroku
heroku addons:add sendgrid:starter
這只是一個每天免費發送 200 封電子郵件的版本(-> 請參閱附加元件說明)
然後,您要建立以下檔案來進行電子郵件設定:* config/configuration.yml *
在這個檔案中,您只需要以下內容(將使用者名稱和密碼調整為您的,您可以透過 heroku 應用程式存取附加元件頁面找到它們)
production:
delivery_method: :smtp
smtp_settings:
address: "smtp.sendgrid.net"
port: 25
authentication: :plain
domain: "heroku.com"
user_name: "SENDGRID_USERNAME"
password: "SENDGRID_PASSWORD"
再次提交並推送您的變更
git add -A git commit -m “adding email configurations” git push heroku 2.5-stable:master
好了,好好享受吧!
我知道這在某些步驟上並不是最簡潔的方法,但它有效,我希望也能幫助到其他人;)
由 Sandro Kolly 更新於 大約 10 年前 · 1 個版本