HerokuでRedmine使ってみた。
Redmineを落とす
$ git clone git://github.com/redmine/redmine.git
$ cd redmine
使用するバージョンを指定する
使いたいバージョンを選んで、git checkoutする。
$ git checkout 2.3-stable
precompile設定をする
#config/application.rb module RedmineApp class Application < Rails::Application config.assets.initialize_on_precompile = false end end
environment.rbを編集する
environment.rbの「exit 1」があるとmigration時に怒られるため、コメントアウトします。*1
# Make sure there's no plugin in vendor/plugin before starting vendor_plugins_dir = File.join(Rails.root, "vendor", "plugins") if Dir.glob(File.join(vendor_plugins_dir, "*")).any? $stderr.puts "Plugins in vendor/plugins (#{vendor_plugins_dir}) are no longer allowed. " + "Please, put your Redmine plugins in the `plugins` directory at the root of your " + "Redmine directory (#{File.join(Rails.root, "plugins")})" # exit 1 end
database.ymlを編集
あらかじめ用意されているスケルトンを編集して、Heroku向けのdatabase.ymlを作成する。
$ cp config/database.yml.example config/database.yml
MySQLの設定をコメントアウトし、下の方にあるPostgreSQLの設定を使用します。
#config/database.yml production: adapter: postgresql database: redmine host: localhost username: postgres password: "postgres" #production: # adapter: mysql2 # database: redmine # host: localhost # username: root # password: "" # encoding: utf8
シークレットトークンを作成する
必要なgemを入れ、secret_token.rbを作成します。*2
$ bundle install $ bundle exec rake generate_secret_token
gitignoreを編集する
作成したシークレットトークンや編集したdatabase.ymlなどをGitの管理対象に加えるために.gitignoreから以下の6行を削除する。
#.gitignore /config/database.yml /config/initializers/session_store.rb /config/initializers/secret_token.rb /public/plugin_assets /Gemfile.lock /Gemfile.local
Heroku上にアプリケーションを作成・設定する
$ heroku apps:create your_app_name $ git push heroku 2.3-stable:master $ heroku run rake db:migrate $ heroku run rake redmine:load_default_data Select language[en]: ja ==================================== Default configuration data loaded. $ heroku restart $ heroku open
heroku openで開ければOKです。
初期アカウントadmin/adminでログインしてアカウントを作成し、admin/adminを削除してください。
補足:PostgreSQLのgemが入らない場合
bundle installしたときに、以下のようなエラーが出て、pgが入らないとこがあります。
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. ~/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for pg_config... no No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Gem files will remain installed in ~/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.15.1 for inspection. Results logged to ~/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.15.1/ext/gem_make.out An error occured while installing pg (0.15.1), and Bundler cannot continue.
$ sudo apt-get install libpq-dev