Wednesday, December 29, 2010

Run Rails2.x and Rails3 Application with Passenger under RVM Ruby Environment .

Create  Add this  in config/setup_load_paths.rb


if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    #puts ENV['MY_RUBY_HOME']
    rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end


Specify The rvm ruby under application virtualhost .

e.g:

 LoadModule passenger_module /home/deploy/.rvm/gems/ruby-1.9.2-p0/gems/passenger-3.0.2/ext/apache2/mod_passenger.so
 PassengerRoot /home/deploy/.rvm/gems/ruby-1.9.2-p0/gems/passenger-3.0.2
 PassengerRuby /home/deploy/.rvm/environments/ruby-1.9.2-p0


All done :


Run apache under sudo'er from user which is set with RVM environment.

No comments: