简体   繁体   English

使用乘客运行 Rails 3.0 和 Rails 3.1 应用程序(使用不同的 rvm gemsets)

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

I just followed these directions for installing a new rvm gemset and installing rails-3.1.0.rc2 on my local machine.我只是按照这些说明在本地计算机上安装新的 rvm gemset 和安装 rails-3.1.0.rc2。 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".起初我收到一个乘客错误,说无法加载 rake-0.9.2 gem,但我发现提醒我运行“$passenger-install-apache2-module”。 It installed fine prompted me to add the following to my Apache config file (/etc/apache2/httpd.conf):它安装得很好,提示我将以下内容添加到我的 Apache 配置文件 (/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:但是,已经有来自不同 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.如果我不加注释(@rails-3.1 gemset 是最后一个),然后重新启动 Apache,我的 Rails 3.0 应用程序将无法启动。 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".我发现自己必须注释掉 rails 3.1 gemset 行,重新启动 Apache,然后运行“$ 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.如果我想运行 Rails 3.1 应用程序,我必须做相反的事情。

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.我以它为例,用 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.您可以告诉Passenger 在没有gemset 的情况下使用ruby 1.9.2,然后在您的每个应用程序中运行rvm 使用ruby-1.9.2-p180 并进行捆绑安装。 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.这意味着您的基础 ruby-1.9.2-p180 将拥有两个应用程序的 gem,并且 bundler 应该处理限制您的应用程序可用的 gem。

End result:最终结果:

  1. ruby-1.9.2-p180 has gems for both apps ruby-1.9.2-p180 对这两个应用程序都有宝石
  2. ruby-1.9.2-p180@rails-3.0 has gems for your 3.0 app ruby-1.9.2-p180@rails-3.0 为您的 3.0 应用程序提供了宝石
  3. ruby-1.9.2-p180@rails-3.1 has gems for your 3.1 app ruby-1.9.2-p180@rails-3.1 为您的 3.1 应用程序提供了宝石
  4. passenger is using ruby-1.9.2-p180乘客正在使用 ruby-1.9.2-p180
  5. bundler should still limit the gems available to each application bundler 仍应限制每个应用程序可用的 gem
  6. both apps should work两个应用程序都应该工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM