开发者

Using passenger to run both Rails 3.0 and Rails 3.1 app (using different rvm gemsets)

开发者 https://www.devze.com 2023-03-11 04:33 出处:网络
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 loa

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 Ap开发者_JAVA百科ache 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?


This article could be useful for you.

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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消