Redmine2.2.0をWindows7 Ruby1.9.3にインストール

投稿日: 2012/12/9 15:48

RedmineをWindows7環境にインストールしていたのですが、
Redmine2.x系からRuby1.9に対応したらしいので
いっそのことRubyからRedmineまで全部入れなおす事にしました。

まずはRuby1.9.3のインストールから。

Windows用のRubyインストーラを公開してくれている以下のWebサイトから
Ruby1.9.3のインストーラを取得します。

Ruby Installer for Windows

インストーラを取得したら普通にインストールで。
何も言わなければ C:\Ruby193\ にインストールされるようです。

続いてRedmineのファイルを展開します。
私の場合は D:\rails\redmine\ に展開します。

Redmine.JP

上記のWebサイト等を参考にしながら最新版を展開するなり、
SVNから取得してくるなりします。

続いてコマンドラインを起動します。
まず最初はgemのインストールからなのですが、
最近のRedmineはbundlerという必要なgemを依存関係を解決して入れてくれる
ソフトに対応したらしいのでこれをインストールします。

[bash]
D:\rails\redmine> gem install bundler
Successfully installed bundler-1.2.3
1 gem installed
Installing ri documentation for bundler-1.2.3…
Installing RDoc documentation for bundler-1.2.3…
[/bash]

続いてカレントディレクトリをRedmineを展開したディレクトリに合わせて
bundlerでgemをインストールします。
なお、Redmine.JPによればOSにImageMagickがインストールされていない場合、
rmagickのインストールを省略する必要があるらしいので
–without development test rmagic を指定します。
多分 development と test は開発用、テスト用のgemを外すんだと思います。

[shell]
D:\rails\redmine>bundle install –without development test rmagick
[/shell]

ここで問題発生。
bundlerで自動的にインストールされる json がビルドできないとのエラーでインストール出来ず。
調べると次のページがヒットしました。

乳牛日記 Windows7環境にgem install rails したらjsonのgemでエラー

これによると先ほどのRuby Installerのページで一緒に公開されていた
DevKitなるものをインストールすれば良いとか。
とりあえずDevKitを C:\DevKit に展開し、コマンドライン実行。
ruby dk.rb init
ruby dk.rb install
の順でいいらしいです。

[shell]
C:\DevKit>ruby dk.rb init
[INFO] found RubyInstaller v1.9.3 at C:/Ruby193

Initialization complete! Please review and modify the auto-generated
‘config.yml’ file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

C:\DevKit>ruby dk.rb install
[INFO] Updating convenience notice gem override for ‘C:/Ruby193’
[INFO] Installing ‘C:/Ruby193/lib/ruby/site_ruby/devkit.rb’

[/shell]

文面を読む限りうまくいったみたいなので再度bundler実行。

[shell]
D:\rails\redmine>bundle install –without development test rmagick
Fetching gem metadata from http://rubygems.org/………
Fetching gem metadata from http://rubygems.org/..
Installing rake (10.0.2)
Installing i18n (0.6.1)
Installing multi_json (1.4.0)
Installing activesupport (3.2.9)
Installing builder (3.0.0)
Installing activemodel (3.2.9)
Installing erubis (2.7.0)
Installing journey (1.0.4)
Installing rack (1.4.1)
Installing rack-cache (1.2)
Installing rack-test (0.6.2)
Installing hike (1.2.1)
Installing tilt (1.3.3)
Installing sprockets (2.2.2)
Installing actionpack (3.2.9)
Installing mime-types (1.19)
Installing polyglot (0.3.3)
Installing treetop (1.4.12)
Installing mail (2.4.4)
Installing actionmailer (3.2.9)
Installing arel (3.0.2)
Installing tzinfo (0.3.35)
Installing activerecord (3.2.9)
Installing activeresource (3.2.9)
Using bundler (1.2.3)
Installing coderay (1.0.8)
Installing rack-ssl (1.3.2)
Installing json (1.7.5) with native extensions
Installing rdoc (3.12)
Installing thor (0.16.0)
Installing railties (3.2.9)
Installing jquery-rails (2.0.3)
Installing mysql2 (0.3.11)
Installing net-ldap (0.3.1)
Installing pg (0.14.1)
Installing ruby-openid (2.1.8)
Installing rack-openid (1.3.1)
Installing rails (3.2.9)
Installing sqlite3 (1.3.6)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported = 1.8.7 : gem install rdoc-data; rdoc-data --install = 1.9.1 : gem install rdoc-data; rdoc-data --install >= 1.9.2 : nothing to do! Yay!
Post-install message from mysql2:

======================================================================================================

You’ve installed the binary version of mysql2.
It was built using MySQL Connector/C version 6.0.2.
It’s recommended to use the exact same version to avoid potential issues.

At the time of building this gem, the necessary DLL files where available
in the following download:

http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

And put lib\libmysql.dll file in your Ruby bin directory, for example C:\Ruby\bin

======================================================================================================

[/shell]

ここから新規構築の場合はsqliteやmysqlなどでデータベース作成や
初期設定を行うのですが、私の場合はRedmine1.3からの移行になるので
新規インストールの場合は以降はRedmine.JPの方を参考にしてください。

ここからのアップグレードはRedmine.JPの次のページを参考にしました。

Redmine.JP アップグレード

バックアップやファイルの移動を行った後、
セッションデータを扱うための秘密鍵を生成します。
前のバージョンで使っていた config\initializers\session_store.rb は
削除しないとダメみたいです。

[shell]
D:\rails\redmine>rake generate_secret_token
[/shell]

続いてデータベースのマイグレーションを行います。

[shell]
D:\rails\redmine>rake db:migrate RAILS_ENV=”production”
== AddUniqueIndexToIssueRelations: migrating =================================
— add_index(:issue_relations, [:issue_from_id, :issue_to_id], {:unique=>true})
-> 0.0156s
== AddUniqueIndexToIssueRelations: migrated (0.0312s) ========================

…省略…

== AddEnumerationsPositionName: migrated (0.0000s) ===========================

== PopulateEnumerationsPositionName: migrating ===============================
== PopulateEnumerationsPositionName: migrated (0.0156s) ======================
[/shell]

プラグインのデータベースマイグレーションも行います。
とはいっても私の場合プラグインが無いので特に何も起こらず。

[shell]
D:\rails\redmine>rake db:migrate_plugins RAILS_ENV=”production”

Note: The rake task db:migrate_plugins has been deprecated, please use the replacement version redmine:plugins:migrate
[/shell]

db:migrate_plugins は古いとか言われてますけどとりあえず無視。

続いてキャッシュとセッションをクリアします。

[shell]
D:\rails\redmine>rake tmp:cache:clear

D:\rails\redmine>rake tmp:sessions:clear

[/shell]

これでほぼOKのはずです。
WEBrickでRedmineを起動してみます。

[shell]
D:\rails\redmine>ruby script\rails server -e production
=> Booting WEBrick
=> Rails 3.2.9 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[/shell]

上記の状態で http://localhost:3000/ にアクセスしたら
上手い事表示されました。

続いてmongrelのインストールとmongrelのサービス化を行うのですが、
そちらは昔のエントリに記載してありますのでそちらを参照してください。

2012/12/11 追記
mongrelインストールでドン詰まりしました。
解決した方法を別エントリに記載しました。