3

我有两个 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第二个应用程序后开始工作,但第一个没有(几乎相同的错误日志)。

4

2 回答 2

1

您正在设置系统范围内的 ruby​​ 版本rvm use...

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

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

于 2013-05-26T11:19:34.570 回答
0

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

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

于 2013-05-26T13:31:49.583 回答