[英]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.