Ami Ami - 1 month ago 8
Apache Configuration Question

My Rails App is not working because passenger is not working

In server, I have installed rails,rvm,apache2 and passenger after installation I drag and drop my rails app to the server, It shows this error.

And in apache2/error/log, It shows bundler load error

App 9573 stdout:
[ 2017-09-21 09:38:10.4331 9419/7f8c7920d700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /var/www/html/vpn_check: An error occurred while starting up the preloader.
Error ID: 9c91492c
Error details saved to: /tmp/passenger-error-lZdumg.html
Message from application: cannot load such file -- bundler/setup (LoadError)
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:430:in `activate_gem'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:297:in `block in run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:435:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:296:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'


I am not sure why im getting this error. Could anyone please help me.

Thanks

Answer Source

You have to configure the rvm ruby version in your apache configuration. In your case Passenger use ruby version in /usr/lib/ruby, instead of rvm ruby version.

If you just use one rvm gemset, you have to configure ruby version and ruby gemset in Passenger apache module (apache/mods-available/passenger.conf) :

PassengerRoot /home/user/.rvm/gems/ruby-version@gemset/gems/passenger-5.1.2
PassengerDefaultRuby /home/user/.rvm/gems/ruby-version@gemset/wrappers/ruby

If you have multiple application running with different rvm configurations, you have to specify ruby version in vhost files.

Exemple :

<Location /appli1>
  PassengerRuby /home/user/.rvm/gems/ruby-2.1@app1/wrappers/ruby
  RackEnv production
  RackBaseURI /appli1
  Options -MultiViews
</Location>
<Location /appli2>
  PassengerRuby /home/user/.rvm/gems/ruby-2.2@app2/wrappers/ruby
  RackEnv production
  RackBaseURI /appli2
  Options -MultiViews
</Location>