Redmineインストール

さくらインターネットスタンダードプランにRedmineを入れる

1. ソースダウンロード(とりあえず0.8系の最新開発版)
※ $Home/srcはソースを格納するためのフォルダ(自分で作成しておく)

$ cd $HOME/src
$ mkdir Redmine
$ cd Redmine
$ svn co svn://rubyforge.org/var/svn/redmine/trunk redmine

2. Redmine設置

$ cp -R $HOME/src/Redmine/redmine $HOME/

3. データベース設定
今回はsqlite3を使用する

$ sqlite3 --version
3.6.14.2

database.yml編集

$ cd $HOME/redmine
$ cp config/database.yml.example config/database.yml
$ vi config/database.yml
production:
  adapter: sqlite3
  dbfile: db/redmine.db
  timeout: 5000

データベース初期化

$ rake db:migrate RAILS_ENV=production
Rails requires RubyGems >= 1.3.1 (you have 1.2.0). Please `gem update --system` and try again.

gemのバージョンが古いと言われたのでRedmineのRailsのバージョンを調べてみると

$ vi $HOME/redmine/config/environment.rb
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

Railsのバージョンが2.2.2だった。Rails2.2以上はRubyGems >= 1.3.1が必要らしい。
ということでRubyGemsアップデート

$ gem18 update --system
Updating RubyGems
Nothing to update

update出来ない。。。
調べてみたらgemでrubygems-updateをインストールしてupdate_rubygemsを実行するっぽい

$ gem18 install rubygems-update
Successfully installed rubygems-update-1.3.4
1 gem installed
Installing ri documentation for rubygems-update-1.3.4...
Installing RDoc documentation for rubygems-update-1.3.4...
$ gem18 list

*** LOCAL GEMS ***

actionmailer (2.1.1)
actionpack (2.1.1)
activerecord (2.1.1)
activeresource (2.1.1)
activesupport (2.1.1)
rails (2.1.1)
rake (0.8.7)
rubygems-update (1.3.4)
$ ls $GEM_HOME/bin
rails           rake            update_rubygems

パッケージ名(rubygems-update)とコマンド名(update_rubygems)が違うけどコマンドの中身を見たらちゃんと

load 'update_rubygems'

してたので納得。
RubyGemsアップデート

$ update_rubygems
Installing RubyGems 1.3.4
Installing RubyGems
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /usr/local/lib/ruby/site_ruby/1.8/gauntlet_rubygems.rb

オプション使って$HOME以下にインストールしてたからうまく出来ない(RubyGemsインストール)。。。
オプション指定して直接実行してみる

$ cd $GEM_HOME/gems/rubygems-update-1.3.4
$ ruby setup.rb --prefix=$HOME/local
Installing RubyGems
Installing gem executable
Removing old source_cache files
Removing old RubyGems RDoc and ri
Installing rubygems-1.3.4 ri into /home/boys-collection/local/lib/ruby/gems/1.8/doc/rubygems-1.3.4/ri
Installing rubygems-1.3.4 rdoc into /home/boys-collection/local/lib/ruby/gems/1.8/doc/rubygems-1.3.4/rdoc

------------------------------------------------------------------------------

Oh-no! Unable to find release notes!

------------------------------------------------------------------------------

RubyGems installed the following executables:
        /home/boys-collection/local/bin/gem18
$ gem18 -v
1.3.4

とりあえず出来たっぽい。
話が大分それたが引き続きRedmineのデータベース初期化

$ cd $HOME/redmine
$ rake db:migrate RAILS_ENV=production
Missing the Rails 2.2.2 gem. Please `gem install -v=2.2.2 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

Rails2.2.2入れてなかった。
Rails2.2.2インストール

$ gem18 install -v 2.2.2 rails --include-dependencies
$ gem18 install -v 2.2.2 rails --include-dependencies
INFO:  `gem install -y` is now default and will be removed
INFO:  use --ignore-dependencies to install only the gems you list
Successfully installed activesupport-2.2.2
Successfully installed activerecord-2.2.2
Successfully installed actionpack-2.2.2
Successfully installed actionmailer-2.2.2
Successfully installed activeresource-2.2.2
Successfully installed rails-2.2.2
6 gems installed
Installing ri documentation for activesupport-2.2.2...
Installing ri documentation for activerecord-2.2.2...
Installing ri documentation for actionpack-2.2.2...
Installing ri documentation for actionmailer-2.2.2...
Installing ri documentation for activeresource-2.2.2...
Installing ri documentation for rails-2.2.2...
Installing RDoc documentation for activesupport-2.2.2...
Installing RDoc documentation for activerecord-2.2.2...
Installing RDoc documentation for actionpack-2.2.2...
Installing RDoc documentation for actionmailer-2.2.2...
Installing RDoc documentation for activeresource-2.2.2...
Installing RDoc documentation for rails-2.2.2...

気を取り直してRedmineのデータベース初期化

$ rake db:migrate RAILS_ENV=production
rake aborted!
no such file to load -- sqlite3

(See full trace by running task with --trace)

sqlite3-ruby入れてなかった。
sqlite3-rubyインストール

$ gem18 install sqlite3-ruby
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
        ERROR: Failed to build gem native extension.

/usr/local/bin/ruby18 extconf.rb
checking for fdatasync() in -lrt... no
checking for sqlite3.h... yes
checking for sqlite3_open() in -lsqlite3... yes
creating Makefile

make
cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -DHAVE_SQLITE3_H -I/usr/local/include -fPIC -O2 -fno-strict-aliasing -pipe  -fPIC  -c sqlite3_api_wrap.c
cc -shared -o sqlite3_api.so sqlite3_api_wrap.o -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L.  -rdynamic -Wl,-soname,sqlite3_api.so   -Wl,-R -Wl,/usr/local/lib -L/usr/local/lib -lruby18 -lsqlite3  -lrt -lcrypt -lm  -rpath=/usr/lib:/usr/local/lib

make install
/usr/bin/install -c -o root -g wheel -m 0755 sqlite3_api.so $HOME/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/lib
install: $HOME/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/lib/sqlite3_api.so: chown/chgrp: Operation not permitted
*** Error code 71

Stop in $HOME/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api.

Gem files will remain installed in $HOME/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to $HOME/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out

パーミッションエラー。。。
検索したら同じ様な人発見

$ less /usr/local/lib/ruby/1.8/i386-freebsd7/rbconfig.rb
  CONFIG["INSTALL"] = ENV['RB_USER_INSTALL'] ? '/usr/bin/install -c' : '/usr/bin/install -c -o root -g wheel'

このRB_USER_INSTALLってやつをtrueにしてあげればOKぽい

$ export RB_USER_INSTALL true
$ gem18 install sqlite3-ruby
Building native extensions.  This could take a while...
Successfully installed sqlite3-ruby-1.2.4
1 gem installed
Installing ri documentation for sqlite3-ruby-1.2.4...
Installing RDoc documentation for sqlite3-ruby-1.2.4...

無事インストール完了
Redmineのデータベース初期化に戻って

rake db:migrate RAILS_ENV=production
==  Setup: migrating ==========================================================
-- create_table("attachments", {:force=>true})
   -> 0.0067s
-- create_table("auth_sources", {:force=>true})
   -> 0.0176s
-- create_table("custom_fields", {:force=>true})
   -> 0.0071s
(以下省略)

やっと出来た。

$ ls redmine/db
migrate         redmine.db      schema.rb

redmine.dbとschema.rbが作成される。
初期データもロード(言語を聞かれるのでjaと入力)

$ rake load_default_data RAILS_ENV=”production”
Select language:
[en]ja

4. Remine起動

$ ruby script/server -e production

ブラウザからアクセスしてみるとInternal Server Error。。。

  Status: 500 Internal Server Error
  A secret is required to generate an integrity hash for cookie session data. Use config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret ph
rase of at least 30 characters" } in config/environment.rb

調べた結果以下を実行すればOKぽい

$ rake config/initializers/session_store.rb

もう一度ブラウザからアクセスするとRedmineが無事表示された。

参考
http://www.redmine.org/projects/redmine
http://redmine.jp/tech_note/install/

タグ:

コメントをどうぞ