簡體   English   中英

升級到Ruby版本2.1.2,乘客仍在1.9.3

[英]Upgraded to Ruby version 2.1.2, passenger still on 1.9.3

每當我使用RVM和Capistrano更新Ruby及其Gemlist時,如何更新乘客使用的Ruby版本? 檢查我的應用程序是否使用正確的紅寶石版本和寶石集的最佳方法是什么?

我有一個運行在Linode服務器(Ubuntu)上的Rails應用程序,帶有NGinx和Passenger。 在運行之前沒有任何問題。

以前我的應用程序在Ruby 1.9.3-p194上運行Ruby on Rails 3.2.16

我使用RVM在本地和服務器上管理ruby版本。 安裝Ruby-2.1.2並更新基本的gem(捆綁程序,nokogiri等)之后,我為應用程序創建了新的gemset。

在開發中(本地),我使用Ruby 2.1.2,rails 3.1.19(在升級到Rails 4之前)以及該項目的特定gemset。

RVM-Capistrano gem集成之后 ,我為Capistrano修改了deploy.rb

require "rvm/capistrano"
require "bundler/capistrano"

set :user, "myusername"
set :application, "myapp"

set :deploy_to, "/home/#{user}/apps/#{application}"
set :scm, :git
set :repository,  "git@github.com:myusername/#{application}.git"
set :branch, "master"
set :rvm_ruby_string, :local              # use the same ruby as used locally for deployment
set :rvm_autolibs_flag, "read-only"       # more info: rvm help autolibs
set :use_sudo, false
set :deploy_via, :remote_cache
set :keep_releases, 3
default_run_options[:pty] = true
set :ssh_options, { :forward_agent => true }

before 'deploy:setup', 'rvm:install_rvm'  # install/update RVM
before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset

after "deploy:restart", "deploy:cleanup"
after "deploy", "rvm:trust_rvmrc"

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end

  # ... some more tasks for assets and symlinks

end

namespace :rvm do
  task :trust_rvmrc do
    run "rvm rvmrc trust #{release_path}"
  end
end

然后我進行cap deploy

我刷新了網頁,乘客出現以下錯誤:

It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:

bundle install
...
Could not find rake-10.3.2 in any of the sources (Bundler::GemNotFound)
/home/myusername/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.5.3/lib/bundler/spec_set.rb:92:in `block in materialize'
...
Ruby interpreter command
/home/myusername/.rvm/gems/ruby-1.9.3-p194/wrappers/ruby

因此,很明顯,Passenger仍在運行Ruby-1.9.3,而不是Ruby-2.1.2。 我不確定RVM-Capistrano是否安裝/更新了Ruby版本和適當的gemset。 我不確定我錯過了什么?

編輯:我檢查了nginx.conf作為/opt/nginx/conf/nginx.conf的root用戶

在文件的頂部,我發現

...

http {
    passenger_root /home/myusername/.rvm/gems/ruby-1.9.3-p194/gems/passenger-4.0.37;
    passenger_ruby /home/myusername/.rvm/gems/ruby-1.9.3-p194/wrappers/ruby;

...

server {
    listen 80;
    server_name XXX.XXX.XX.XX myapp.com www.myapp.com *.myapp.com;
    root /home/myusername/apps/myapp/current/public;
    passenger_enabled on;
    client_max_body_size 4G;
}

這是否意味着我必須用ruby-2.1.2更改這些行? 有沒有辦法自動執行此更改?

更新2:我修改了nginx.conf

http {
        passenger_root /home/myusername/.rvm/gems/ruby-2.1.2@rails3.2/gems/passenger-4.0.53;
        passenger_ruby /home/myusername/.rvm/gems/ruby-2.1.2@rails3.2/wrappers/ruby;

在我的deploy.rb我明確告訴要使用gemset ruby-2.1.2@rails3.2

set :rvm_ruby_string, "2.1.2@rails3.2"

該應用程序運行良好,Ruby Interpreter仍為1.9.3。 我什至在管理頁面上打印了RUBY_VERSION常數,它顯示1.9.3

我不明白

謝謝你的幫助

如果使用Passenger 4或更高版本,則可以使用由rvm管理的多個紅寶石版本。

在這里,您有一些指南鏈接

http://rvm.io/integration/passenger
https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html
https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html

看起來要在服務器上運行乘客安裝/升級,您必須先運行rvmsudo -s

您應該從新的RVM上下文中運行passenger-install-nginx-module ,以實際安裝新的passenger模塊。 更多信息在這里:

https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#run_passenger_installer

Nginx與其他Web服務器的不同之處在於它不支持可加載模塊。 擴展Nginx的唯一方法是完全從源代碼進行重新編譯。 由於Phusion Passenger由一些外部可執行文件以及Nginx模塊組成,因此,在首次安裝Phusion Passenger時,以及在升級Nginx本身或升級Phusion Passenger版本時,都必須重新編譯Nginx。

因此,手動更改nginx配置是不夠的,您應該運行乘客安裝程序,該安裝程序應注意正確設置nginx(即重新編譯所需的內容)。 我通常使用apache乘客模塊,並在升級后始終運行乘客安裝程序。 只需確保在運行乘客安裝程序之前rvm use ruby-2.1.2@rails3.2運行rvm use ruby-2.1.2@rails3.2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM