- 追加された行はこの色です。
- 削除された行はこの色です。
&tag(CentOS5/Redmine);
*目次 [#s7b41907]
#contents
*参考情報 [#k6d5de61]
*Redmine [#w364ccc5]
**参考情報 [#td9ab251]
-[[Redmine 1.1をCentOS5.5にインストールする手順 | Redmine.JP Blog:http://blog.redmine.jp/articles/redmine-1_1-installation_centos/]]
**概要 [#tfe180b2]
-Rubyは自前でソースからビルドしてインストールする。
-Ruby関連のライブラリはgemsを使ってインストールする。
-データベースはとりあえずsqlite3。
-自動起動にはPassengerを使う。
-特に注意しないといけないのは「最新版のgemsを使うとはまる」ということ。
**必要なライブラリのインストール [#b8b07409]
-sqlite3のインストール
$ sudo yum install sqlite3-devel
**Rubyのインストール [#a3b04185]
-標準のRubyは1.8.5と古いのでソースからコンパイルしてインストールする。
-[[ダウンロード:http://www.ruby-lang.org/ja/downloads/]]からruby-1.9.2-p180.tar.bz2をダウンロードする。
-tarで展開後、 configure, make, make installを実行。
$ tar jxvpf ruby-1.8.7-p334.tar.bz2
$ cd ruby-1.8.7-p334
$ ./configure
$ make
$ sudo make install
**RubyGemsのインストール [#e80f0ff6]
-[[RubyForge: RubyGems: ファイルリスト:http://rubyforge.org/frs/?group_id=126&release_id=17305]]からrubygems-1.7.1.tgz。
-展開してインストール。
$ tar zxvpf rubygems-1.7.1.tgz
$ cd rubygems-1.7.1
# ruby setup.rb
-gemsの更新(必要ないかも)
# gem update --system
-gemsのダウングレード
# gem update --system 1.4.2
**Ruby関連ライブラリのインストール [#ga2b6ad8]
-sqlite3-rubyをインストール。最新版だとエラーになるので古いのをインストール。
$ sudo gem install sqlite3-ruby --version=1.2.5
-rakeをインストール [#xfc9cf0c]
$ sudo gem install rake
-i18nのインストール
$ sudo gem install -v=0.4.2 i18n
-railsのインストール
$ sudo gem install rails --version 2.3.11
**Redmineのインストール [#t222ee05]
-[[Redmine.JP:http://redmine.jp/]]から最新版をダウンロード。今回はredmine-1.1.2.tar.gzを使用。
**設定 [#t5439ecd]
-config/database.yml.exampleをconfig/database.ymlにコピーして編集する。
#pre{{
production:
adapter: sqlite3
database: db/redmine.db
timeout: 5000
}}
-session_storeを作成する。
$ rake config/initializers/session_store.rb
-データベースを作成する。
$ rake db:migrate RAILS_ENV=production
-デフォルトデータの投入
$ rake redmine:load_default_data RAILS_ENV=production
**動作確認 [#x35db5e8]
-script/serverを実行する。
$ script/server -e production
-http://localhost:3000にアクセス。
**Passengerを使って自動起動 [#b17954c6]
-gemを使ってインストール
# gem install passenger
-インストーラーを起動。画面に指示が表示されるのでたらないライブラリなどが存在する場合はyumを使ってインストールする。
# passenger-install-apache2-module
-httpd.confを編集(これもインストーラーの最後で表示される)
#pre{{
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.5/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.5
PassengerRuby /usr/local/bin/ruby
}}
-http://localhost/redmineのようにサブディレクトリで起動する場合、/var/www/htmlに、redmineのpublic_htmlディレクトリのシンボリックリンクをはる。
ln -s /home/redmine/public_html /var/www/html/redmine
-http://localhost/redmineにアクセス。
**mongrelとmongrel_clusterを使って自動起動 [#qea6da58]
***結局うまくいかず [#f3f2b0ac]
-&color(red){最後までやってみたもののログインしようとすると「Invalid Authenticity Token error」と表示されログインできないので、Passengerを使うことにしました};
-ちなみに、[[#4690 Mongrel doesn't work with rails 2.3.8 - Ruby on Rails - rails:https://rails.lighthouseapp.com/projects/8994/tickets/4690]]が関係るのか。config/initializerにパッチを当てたバージョンのmongrel.rbをおき、さらにmongrel.rbの冒頭のrailsのバージョン判定をしているところに2.3.5を追加すればログインログアウトできるところまで確認。
***一応の手順 [#ve50cfe0]
-インストールする
$ sudo gem install mongrel
$ sudo gem install mongrel_cluster
-まずmongrel(mongrel_rails)で単独で動作するか確認。
$ mongrel_rails -e production
-mongreul_clusterを使い自動起動するようにする。まず設定ファイルを書き出す。redmineのルートディレクトリに移動してコマンドを実行する。
# mongrel_rails cluster::configure -e production
-config/mongrel_cluster.ymlが書き出される
#pre{{
---
log_file: log/mongrel.log
port: 3000
cwd: /home/redmine
environment: production
pid_file: tmp/pids/mongrel.pid
servers: 2
}}
-/etc/mongrel_clusterディレクトリを作成し、そこにmongrel_cluster.ymlのリンクをはる
# mkdir /etc/mongrel_cluster
# ln -s /home/redmine/config/mongrel_cluster.yml /etc/mongrel_cluster/redmine.yml
-スタートアップスクリプトを/etc/init.dにコピー。
# cp /usr/local/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/
-ユーザー設定。mongrel_clusterの冒頭にmongrel_cluster起動用ユーザー名が指定されているので(apacheなどに)変更するか、ユーザーを追加する。
-実行権限を追加
# sudo chmod +x /etc/init.d/mongrel_cluster
-自動起動設定
# sudo /sbin/chkconfig --level 345 mongrel_cluster on
**トラブルシューティング [#o3f51b02]
***db:migrateを実行すると「RubyGem version error: rack(1.2.1 not ~> 1.0.1)」といわれる。 [#l3be2826]
-rackのバージョンがあってないのが原因らしい。
-action_controller.rbを編集し、1.0.1を1.2.1に書き換える(vendor/rails/actionpack/lib/action_controller.rbの34行目)
gem 'rack', '~> 1.2.1'
**トラブルシューティング2(基本的に不要) [#o05e480d]
-gemsのバージョンを新しくしてもがいたときの記録を参考までに。
-gemsは正しく古いバージョンを使いましょう。
***uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) [#f4dae32e]
-config/boot.rbにrequire 'thread'を追加。
***undefined local variable or method `version_requirements' for #<Rails::GemDependency:0xb7b1d3a4> [#s40be1bd]
[[Redmine - Defect #7516: Redmine does not work with RubyGems 1.5.0 - Redmine:http://www.redmine.org/issues/7516]]によるとconfig/environment.rbに次のコードを追加する。
#pre{{
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
end
end
end
}}
***SourceIndex.new(hash) is deprecatedと警告が表示されてうっとうしい [#ce8e9ec1]
-vendor/rails/railties/lib/rails/vendor_gem_source_index.rbの100行目が原因。
-とりあえずwarnの警告を非表示にするだけなら$VERBOSEをnilにすればいいらしい。
#pre{{
verbose = $VERBOSE
$VERBOSE = nil
@vendor_source_index = Gem::SourceIndex.new(vendor_gems)
$VERBOSE = verbose
}}