Using RVM rubies with Passenger
RVM will allow you to use any of it's MRI/YARV rubies with passenger very easily.
Passenger with RVM
Select a Passenger Ruby and Generate Wrapper Scripts
Run RVM using your desired Ruby interpreter, and pass the '--passenger' option. This will generate wrapper scripts in RVM's bin directory (see Notes below). These wrapper scripts ensure environment variables such as GEM_HOME and GEM_PATH are set correctly for applications run by passenger. E.g:
rvm ree --passenger
Alternatively, you can use the rvm wrapper command directly:
rvm wrapper ree@ninjas passenger
Install Passenger
rvm ree gem install passenger rvmsudo passenger-install-nginx-module
Or if you are forced to use the tomahawk,
rvmsudo passenger-install-apache2-module
Configure the Web Server
For Nginx users, replace the passenger_ruby line with:
passenger_ruby /home/wayne/.rvm/bin/passenger_ruby;
For apache users, use:
PassengerRuby /home/wayne/.rvm/bin/passenger_ruby
Please note that if you installed rvm as root / are using a system wide ruby, instead of using /home/wayne/.rvm/bin/passenger_ruby as in the above examples, you'll instead need to use /usr/local/bin/passenger_ruby.
Notes
- Do no not forget to configure the production environment and/or to set the rails_env/RailsEnv variable to development into nginx.conf/httpd.conf for the virtual server config block. The RAILS_ENV defaults to 'production'.
- Be sure to change '/home/wayne' in the above examples to your own $HOME directory,
- The '.rvm/bin/passenger_ruby' is actually what is known as a 'wrapper script' which sets up the environment for the passenger so that it can find it's gems, etc... and then exec's the actual ruby binary."
-
passenger_root/PassengerRoot Should be something similar to the following, which
is for Passenger 2.2.11 installed under ree-1.8.7-2010.01.
passenger_root /home/millisami/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11
Troubleshooting
- The most common issue is forgetting the /bin/ part of the path to get the proper wrapper script:
-
The next most common issue is listening to the output of the passenger installation script with
respect to where passenger_ruby/PassengerRuby are located. Be sure to use the wrapper script location
as specified above. To be more clear, see the example below for Nginx config:
passenger_ruby /home/wayne/.rvm/bin/passenger_ruby; * NOTICE THE '.rvm/bin' DIR ^ ^ ^ * do NOT use the actual ruby binary in .rvm/rubies/{passenger_ruby}/bin/ruby * do not listen to passenger's output for passenger_ruby as passenger is not aware of rvm.For system wide (root) installs the bin directory is /usr/local/bin instead:passenger_ruby /usr/local/bin/passenger_ruby;
FAQ
-
Q: Can I run multiple projects under passenger with each project on a different ruby version?
A: Not at this time. Passenger currently only supports running it's projects under *one* ruby. You can get this behavior using a proxy pass.
-
Q: How do I use custom gemsets under passenger?
A: Without bundler you can either set environment variables yourself in your config.ru like:
ENV["GEM_HOME"]=%x{"source ~/.bash_profile ; rvm ree@pancake ; rvm gemdir"}.stripOr, if you are already using rvmrc's, you can use the rvm ruby api and config/setup_load_paths.rb in recent passenger versions by following the guide located here.
A: With bundler: Install bundler outside any gemset, switch back to the gemset you wish to use and run bundle install and restart the application (by touching tmp/restart.txt). This works becase bundler stores absolute paths inside .bundle/environment.rb which will be loaded by bundler directly. If this doesn't work as expected, try running bundle install like so:
bundle install $BUNDLE_PATH