我有两个 RoR 应用程序,一个使用 ruby 2.0.0 和名为 dataentry3 的 gemset(rvm 使用 2.0.0@dataentry3),第二个应用程序使用 ruby 1.9.3@v1。
我尝试通过以下方式部署这些应用程序:
rvm use ruby-2.0.0@dataentry3
cd dir/app1
gem install passenger
passenger-install-nginx-module
编辑 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; } } }
- 一切正常(
http://my-ip
)。
在这些步骤之后,我尝试在地址上部署第二个应用程序http://my-ip/v1
(新的 phusion 乘客允许运行多个 ruby 版本,请参见此处)
我做的步骤:
rvm use ruby-1.9.3@v1
cd dir/app2
gem install passenger
编辑 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
第二个应用程序后开始工作,但第一个没有(几乎相同的错误日志)。