简体   繁体   English

如何为具有不同Ruby版本的两个Rails应用程序创建服务器设置?

[英]How do I create a server setup for two Rails apps with different Ruby versions?

I have a large instance of EC2. 我有一个很大的EC2实例。 I have a application using Rails 4.0 and Ruby 2.0, running using Unicorn. 我有一个使用Rails 4.0和Ruby 2.0的应用程序,使用Unicorn运行。

I want to deploy another, very small, application using Rails 4.0.1 and Ruby 2.1 on the instance. 我想在实例上使用Rails 4.0.1和Ruby 2.1部署另一个非常小的应用程序。

Can I use Unicorn for both apps? 我可以在两个应用程序中使用Unicorn吗? If not, can I use Nginx + Unicorn for both? 如果没有,我可以使用Nginx + Unicorn吗? What would be appropriate approach for this? 对此有什么合适的方法?

I wanted to use Nginx+passenger but that wont support different Ruby versions. 我想使用Nginx +乘客,但不支持不同的Ruby版本。

This is a sample Nginx configuration, which doesn't work because both applications need different Ruby versions: 这是一个示例Nginx配置,它不起作用,因为两个应用程序都需要不同的Ruby版本:

http {
  passenger_root /home/prasad/.rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.18;
  passenger_ruby /home/prasad/.rvm/wrappers/ruby-1.9.3-p286/ruby;
  ...
  server {
    listen       80;
    server_name  dev.app1; #uses ruby 1.9.3
    passenger_enabled on;
    root   /home/prasad/projects/app1/public;
    rails_env development;
  }

  server {
    listen       80;
    server_name  dev.app2; #uses ruby 2.0
    passenger_enabled on;
    root   /home/prasad/projects/app2/public;
    rails_env development;
  }
  ...

I am looking for a solution where I can run multiple applications with different stacks. 我正在寻找一个解决方案,我可以运行不同堆栈的多个应用程序。

The solution is to upgrade to v4 or greater of Passenger, so that you can configure the Ruby version per application. 解决方案是升级到V4或更高版本的Passenger,以便您可以为每个应用程序配置Ruby版本。

Essentially, in addition to the HTTP block where you have "passenger_ruby" globally configured in your example, you can specify a separate Ruby per server : 实质上,除了在您的示例中全局配置了“passenger_ruby”的HTTP块之外,您还可以为每个服务器指定一个单独的Ruby:

server {
  # This Rails web app will use Ruby 1.9.3, as installed by RVM
  passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3/ruby;
  ...
}

See the full documentation at : http://www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerRuby 请参阅以下完整文档: http//www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerRuby

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

相关问题 如何在具有不同Ruby / Rails版本的两个应用程序上工作? - How do I working on two apps with different Ruby/Rails versions? 具有不同的ruby和rails版本的rails的服务器设置选项 - Server setup option for rails with different ruby and rails versions 同一服务器上不同Ruby版本上的多个Rails应用 - Multiple Rails apps on different Ruby versions on the same server 如何在使用不同版本的rails的rails应用程序上运行ruby? - How to run ruby on rails apps with different versions of rails? 一台服务器上的2个ruby应用程序具有不同的Ruby版本 - 2 ruby apps on one server with different Ruby versions 如何在两个不同的Rails应用程序中使用一个数据库 - How do i work with one database in two different rails apps 我们可以安装两个不同版本的ruby并将它们映射到同一服务器上各自版本的rails吗? - Can we install two different versions of ruby and map them to respective versions of rails on the same server? 如何在Ruby on Rails支持的站点上设置两个用户之间的共享会话? - How do I setup a shared session between two users on my Ruby on Rails powered site? 如何切换到旧版本的ruby / rails环境? - How do I switch to older versions of the ruby/rails environment? 如何在不同 Ruby 版本的轨道上远程协作? - How to collaborate remotely in rails with different Ruby versions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM