Using passenger to run both Rails 3.0 and Rails 3.

2019-05-16 10:43发布

问题:

I just followed these directions for installing a new rvm gemset and installing rails-3.1.0.rc2 on my local machine. At first I was getting a Passenger error saying the rake-0.9.2 gem could not be loaded, but I found this reminding me to run "$ passenger-install-apache2-module". It installed fine prompted me to add the following to my Apache config file (/etc/apache2/httpd.conf):

LoadModule passenger_module /Users/robs/.rvm/gems/ruby-1.9.2-p180@rails-3.1/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /Users/robs/.rvm/gems/ruby-1.9.2-p180@rails-3.1/gems/passenger-3.0.7
PassengerRuby /Users/robs/.rvm/wrappers/ruby-1.9.2-p180@rails-3.1/ruby

However, there are already three lines there from a different gemset:

LoadModule passenger_module /Users/robs/.rvm/gems/ruby-1.9.2-p180@rails-3.0/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /Users/robs/.rvm/gems/ruby-1.9.2-p180@rails-3.0/gems/passenger-3.0.7
PassengerRuby /Users/robs/.rvm/wrappers/ruby-1.9.2-p180@rails-3.0/ruby

If I leave both sets of lines there uncommented (the @rails-3.1 gemset's is last), and restart Apache, my Rails 3.0 app won't start. I find myself having to comment out the rails 3.1 gemset lines, restart Apache, and then run "$ rvm use ruby-1.9.2-p180@rails.3.0". If I want to run the Rails 3.1 app, I have to do the opposite.

Is there a way to have both be able to run at the same time without these extra steps?

回答1:

This article could be useful for you.

I used it as an example to setup my own development environment with nginx.



回答2:

You could tell Passenger to use ruby 1.9.2 without a gemset, then in each of your apps run rvm use ruby-1.9.2-p180 and bundle install. This means your base ruby-1.9.2-p180 will have the gems for both applications, and bundler should handle limiting the gems available to your application.

End result:

  1. ruby-1.9.2-p180 has gems for both apps
  2. ruby-1.9.2-p180@rails-3.0 has gems for your 3.0 app
  3. ruby-1.9.2-p180@rails-3.1 has gems for your 3.1 app
  4. passenger is using ruby-1.9.2-p180
  5. bundler should still limit the gems available to each application
  6. both apps should work