在nginx上部署乘客的多个Ruby on Rails应用程序

我有两个RoR应用程序,一个是使用ruby 2.0.0,名为dataentry3的gemset(rvm使用2.0.0@dataentry3),第二个应用程序使用ruby 1.9.3@v1。

我尝试按以下方式部署这些应用程序:

  1. rvm use ruby-2.0.0@dataentry3
  2. cd dir/app1
  3. gem install passenger
  4. passenger-install-nginx-module
  5. 编辑nginx.conf:

     http { passenger_root /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3; server { listen 80; server_name localhost; location / { passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p195@dataentry3/ruby; root /var/www/adgally/dataentry4/public; passenger_enabled on; } } } 
  6. 一切工作正常( http://my-ip )。

经过这些步骤之后,我尝试在地址http://my-ip/v1上部署第二个应用程序(新的phusion乘客允许运行多个ruby版本, 请参阅此处 )

我做的步骤:

  1. rvm use ruby-1.9.3@v1
  2. cd dir/app2
  3. gem install passenger
  4. 编辑nginx.conf:

     http { passenger_root /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3; server { listen 80; server_name localhost; location / { passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p195@dataentry3/ruby; root /var/www/adgally/dataentry4/public; passenger_enabled on; } location /v1 { passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.3-p429@v1/ruby; root /var/www/adgally/v1/public; passenger_enabled on; } } } 

在此之后,第二个应用程序( http://my-ip/v1 )不起作用。 我收到错误:

 Permission denied - /nonexistent (Errno::EACCES) /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir' /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:247:in `fu_mkdir' /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:221:in `block (2 levels) in mkdir_p' /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:219:in `reverse_each' /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:219:in `block in mkdir_p' /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:205:in `each' /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:205:in `mkdir_p' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/lib/phusion_passenger/native_support.rb:145:in `mkdir' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/lib/phusion_passenger/native_support.rb:162:in `block in compile' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/lib/phusion_passenger/native_support.rb:160:in `each' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/lib/phusion_passenger/native_support.rb:160:in `each_with_index' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/lib/phusion_passenger/native_support.rb:160:in `compile' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/lib/phusion_passenger/native_support.rb:138:in `compile_and_load' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/lib/phusion_passenger/native_support.rb:37:in `start' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/lib/phusion_passenger/native_support.rb:205:in `<top (required)>' /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/helper-scripts/rack-preloader.rb:48:in `init_passenger' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/helper-scripts/rack-preloader.rb:126:in `<module:App>' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>' /usr/local/rvm/gems/ruby-2.0.0-p195@dataentry3/gems/passenger-4.0.3/helper-scripts/rack-preloader.rb:5:in `<main>' 

ruby-2.0.0和ruby-1.9.3游戏gem之间肯定会有冲突。 我不明白为什么,因为新版本的乘客是支持这个的。 更改passenger_root指令到/usr/local/rvm/gems/ruby-1.9.3-p429@v1/gems/passenger-4.0.3第二个应用程序开始工作后,但第一个不(几乎相同的错误日志)。

您正在rvm use...系统设置红宝石版本rvm use...

您需要在您的虚拟主机中使用PassengerRuby选项,请检查此链接到乘客文档: http : //www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerDefaultRuby

也可以尝试为每个应用程序使用单独的虚拟主机。

/ nonexistant是“nobody”用户的主目录。 换句话说,Phusion Passenger试图以“nobody”用户身份运行您的应用程序,并且因为该用户没有有效的主目录而失败。

您可能不打算将您的应用作为“无人”用户运行。 为了解决这个问题,将你的config.ru配置为你想运行的用户。 有关更多信息,请阅读Phusion Passenger中的用户切换支持 。