ふそうごむ。by扶桑ゴム産業

扶桑ゴム産業の最新情報とうぇぶますたあ「TKYK」の個人的日記。

死ぬほど手こずった、Redmine0.8.7→1.0.1アップグレード

なんか、Redmineの最新版だと子チケットができるらしいね、便利だね、この際アップグレードしとこうか?と気軽に受けたのが悪夢の始まりだった(笑)

以下は意外に手こずり、エラーメッセージが出まくり、心がおれるようなRedmineアップグレードの顛末(涙)

そもそもの原因は、redmine0.9系へのアップグレード失敗談にあるとおり、直接コピーしてしまったことと、きちんと痕跡を残さずruby関連を消去していなかったことにあるようだ。
(参考:CentOS5.4へのRuby1.8.7+Rails2.3.5のインストールメモ

 # rpm -qa |grep ruby
 # rpm -e (でてきた関連パッケージを記述)
 # rm -Rf /usr/bin/ruby
 # rm -Rf /usr/lib/ruby
rpmコマンドでruby関連を探して消去するだけでなく、ディレクトリも消去。その上で、きちんと
 make clean

などしてmakeももう一回やるつもりで作成するとうまくいった…。

特にrubyの最新バージョンは1.9.2だが、これだとうまく動かない可能性があるので1.8.7の最終バージョンを用い、railsなどもバージョンに気をつける

Rubyのアップグレード
 # wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p302.tar.gz
 # tar zxvf ruby-1.8.7-p302.tar.gz
 # cd ruby-1.8.7-p302
 # ./configure --prefix=/usr
 # make
 # checkinstall --fstrans=no
 # rpm -i /usr/src/redhat/RPMS/i386/ruby-1.8.7-p302-1.i386.rpm

rubygemのインストール
# wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
# tar zxvf rubygems-1.3.7.tgz
# cd rubygems-1.3.7
# checkinstall -R "ruby setup.rb"
# rpm -i /usr/src/redhat/RPMS/i386/rubygems-1.3.7-1.i386.rpm
gemにてRailsをアップデート。必要とされるバージョンは2.2.2。
# gem install rails -v=2.2.2
mysqlも。
# gem install mysql

Passenger(mod_rails for Apache)をアップグレードインストール。
 
# gem install passenger
# passenger-install-apache2-module
この後の画面が色がついていて(?)ターミナルからだととにかく見にくい。
以下のような表示がされているので、「1(enter)」「(enter)」と押す。
 Welcome to the Phusion Passenger Apache 2 module installer, v2.2.15.
 
 This installer will guide you through the entire installation process. It
 shouldn't take more than 3 minutes in total.
 
 Here's what you can expect from the installation process:
 
  1. The Apache 2 module will be installed for you.
  2. You'll learn how to configure Apache.
  3. You'll learn how to deploy a Ruby on Rails application.
 
 Don't worry if anything goes wrong. This installer will advise you on how to
 solve any problems.
 
 Press Enter to continue, or Ctrl-C to abort.
 1
 
 --------------------------------------------
 Compiling and installing Apache 2 module...
 The Apache 2 module was successfully installed.
 
 Please edit your Apache configuration file, and add these lines:
 
    LoadModule passenger_module
      /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
    PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15
    PassengerRuby /usr/bin/ruby
 
 After you restart Apache, you are ready to deploy any number of Ruby on Rails
 applications on Apache, without any further Ruby on Rails-specific
 configuration!
 
 Press ENTER to continue.
viで、Apacheredmine.conf設定ファイルを編集。
 # vi /etc/httpd/conf.d/redmine.conf
LoadModule passenger_module
   /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15/ext/apache2/mod_passenger.so
 PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15
 PassengerRuby /usr/bin/ruby
そして、Apacheを再起動。
 # service httpd restart

ここまでが下準備なのです(涙)
さあ、いよいよRedmineのアップグレード!
 # cd /webroot/local/www/redmine
 # rake db:migrate RAILS_ENV="production"
 (in /var/www/redmine)
 rake aborted!
 RubyGem version error: rack(1.2.1 not ~> 1.0.1)
 
 (See full trace by running task with --trace)
エラーが出てしまう。rackが新しすぎるらしい。一旦rackをアンインストールし、1.0.1をインストールするようにする。
 # gem uninstall rack
 Remove executables:
         rackup
 
 in addition to the gem? [Yn]  Y
 Removing rackup
 
 You have requested to uninstall the gem:
         rack-1.2.1
 passenger-2.2.15 depends on [rack (>= 0)]
 If you remove this gems, one or more dependencies will not be met.
 Continue with Uninstall? [Yn]  Y
 Successfully uninstalled rack-1.2.1
# gem install rack -v 1.0.1
 Successfully installed rack-1.0.1
 1 gem installed
 Installing ri documentation for rack-1.0.1...
 Installing RDoc documentation for rack-1.0.1...
再度挑戦!
 # rake db:migrate RAILS_ENV="production"
 (in /var/www/redmine)
 ==  AddCustomFieldsEditable: migrating ========================================
 -- add_column(:custom_fields, :editable, :boolean, {:default=>true})
    -> 0.7291s
 ==  AddCustomFieldsEditable: migrated (0.7299s) ===============================
 
 ==  SetCustomFieldsEditable: migrating ========================================
 ==  SetCustomFieldsEditable: migrated (0.1005s) ===============================
 
 ==  AddProjectsLftAndRgt: migrating ===========================================
 (略)
 ==  ChangeChangesPathLengthLimit: migrating ===================================
 -- change_column(:changes, :path, :text, {:null=>true, :default=>nil})
    -> 0.0292s
 -- change_column(:changes, :path, :text, {:null=>false})
    -> 0.0160s
 -- change_column(:changes, :from_path, :text)
    -> 0.0376s
 ==  ChangeChangesPathLengthLimit: migrated (0.0837s) ==========================
 
 ==  EnableCalendarAndGanttModulesWhereAppropriate: migrating ==================
 ==  EnableCalendarAndGanttModulesWhereAppropriate: migrated (0.0470s) =========
インストール完了!!
こうして、ようやくRedmineの最新版へとアップグレードできたのでありました…