Heroku に Redmine を設置する手順
Heroku に Ruby製プロジェクト管理ソフト Redmine を設置したので、手順をご紹介します。
・公式:Redmine.JP
Heroku への Redmineの導入手順は下記のサイトを参考にしました。ありがとうございます。
・Herokuにredmineを設置する « yukku@wp
Redmineのダウンロード/展開
wget http://rubyforge.org/frs/download.php/75593/redmine-1.2.3.tar.gz tar zxvf redmine-1.2.3.tar.gz mv redmine-1.2.3 redmine-bkr cd redmine-bkr/ |
Herokuにインストールするgemを指定する
Redmineは、Rails, Rack, i18nのバージョンがちゃんと揃ってないと、動作しないらしいので公式ブログを参考にして .gem ファイルを作成します。
・参考:Redmine 1.2をCentOS5.6にインストールする手順 | Redmine.JP Blog
■ .gems
rails --version 2.3.11 rack --version 1.1.1 i18n --version 0.4.2 |
Heroku用にソースコード編集
Heroku 上で動作する Railsアプリケーションは /tmp 以下にしかファイルを作れないので、添付ファイルなどの保存先を変更します。
まず、必要なディレクトリを作成します。空のディレクトリを git は追加できないのでダミーファイルも一緒に作成します。
mkdir tmp/files mkdir tmp/plugin_assets touch tmp/files/dummy touch tmp/plugin_assets/dummy |
次に、該当するファイルを編集します
■ app/models/attachment.rb
46 | @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{RAILS_ROOT}/files" |
↓(変更)
46 | @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{RAILS_ROOT}/tmp/files" |
■ vendor/plugins/engines/lib/engines.rb
51 | self.public_directory = File.join(RAILS_ROOT, 'public', 'plugin_assets') |
↓(変更)
51 | self.public_directory = File.join(RAILS_ROOT, 'tmp', 'plugin_assets') |
セッション用のシークレットキー設定を追記します。
■ config/environment.rb
config.action_controller.session = { :key => "_my_redmine_session", :secret => "some-secret-phrase-over-30-length" } |
DBの設定をします。
■ config/database.yml
cp config/database.yml.example config/database.yml vim config/database.yml |
production: adapter: postgresql database: redmine host: localhost username: postgres password: "postgres_passwd" |
メールサーバの設定をします。
■ config/configuration.yml
cp config/configuration.yml.example config/configuration.yml vim config/configuration.yml |
production: email_delivery: delivery_method: :smtp smtp_settings: address: "localhost" port: 25 domain: 'yourappname.heroku.com' |
Gitの初期化/コミット
git init git add . git commit -m 'init' |
Herokuアプリ作成/デプロイ
heroku create git push heroku master heroku rake db:migrate |
動作確認
heroku open |
以上、Heroku に Redmine を deploy したい、現場からお送りしました。