简体   繁体   English

Ruby on Rails 服务器设置

[英]Ruby on Rails server setup

I'm trying to deploy ROR application to Ubuntu server(EC2).我正在尝试将 ROR 应用程序部署到 Ubuntu 服务器(EC2)。 I'm using following versions:我正在使用以下版本:

  • Ruby : 2.4.0p0红宝石:2.4.0p0
  • Rails : 4.2.8导轨:4.2.8
  • Bundler : 1.17.3捆绑器:1.17.3

*For some reason my colleague has created a gemset instead of normal setup. *出于某种原因,我的同事创建了一个 gemset 而不是正常设置。

gem env is:宝石环境是:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.8
  - RUBY VERSION: 2.4.0 (2016-12-24 patchlevel 0) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/ubuntu/.rvm/gems/ruby-2.4.0@myrepo
  - USER INSTALLATION DIRECTORY: /home/ubuntu/.gem/ruby/2.4.0
  - RUBY EXECUTABLE: /home/ubuntu/.rvm/rubies/ruby-2.4.0/bin/ruby
  - EXECUTABLE DIRECTORY: /home/ubuntu/.rvm/gems/ruby-2.4.0@myrepo/bin
  - SPEC CACHE DIRECTORY: /home/ubuntu/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/ubuntu/.rvm/gems/ruby-2.4.0@myrepo
     - /home/ubuntu/.rvm/gems/ruby-2.4.0@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/ubuntu/.rvm/gems/ruby-2.4.0@myrepo/bin
     - /home/ubuntu/.rvm/gems/ruby-2.4.0@global/bin
     - /home/ubuntu/.rvm/rubies/ruby-2.4.0/bin
     - /home/ubuntu/.rvm/bin
     - /home/ubuntu/bin
     - /home/ubuntu/.local/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /snap/bin



I did the setup of nginx and passenger and set the root paths.我完成了 nginx 和乘客的设置并设置了根路径。

  • nginx version: nginx/1.17.3 nginx 版本:nginx/1.17.3
  • Phusion Passenger : 6.0.4 Phusion 乘客:6.0.4

I believe there is nothing wrong with nginx and passenger's settings but I'm getting following error: The Phusion Passenger application server tried to start the web application.我相信 nginx 和乘客的设置没有任何问题,但我收到以下错误:Phusion 乘客应用程序服务器尝试启动 Web 应用程序。 But the application itself (and not Passenger) encountered an internal error.但是应用程序本身(而不是Passenger)遇到了内部错误。

Error details:错误详情:

cannot load such file -- bundler/setup (LoadError)
  /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:363:in `activate_gem'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:221:in `block in run_load_path_setup_code'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:527:in `running_bundler'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:220:in `run_load_path_setup_code'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:91:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:380:in `run_block_and_record_step_progress'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'

The stdout/stderr output of the subprocess so far is:到目前为止,子进程的 stdout/stderr 输出是:

 [passenger_native_support.so] trying to compile for the current user (nobody) and Ruby interpreter...
     (set PASSENGER_COMPILE_NATIVE_SUPPORT_BINARY=0 to disable)
     Warning: compilation didn't succeed. To learn why, read this file:
     /tmp/passenger_native_support-18gfm98.log
 [passenger_native_support.so] finding downloads for the current Ruby interpreter...
     (set PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 to disable)
     Could not download https://github.com/phusion/passenger/releases/download/release-6.0.4/rubyext-ruby-2.4.0-x86_64-linux.tar.gz: The requested URL returned error: 404 Not Found
     Trying next mirror...
     Could not download https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/6.0.4/rubyext-ruby-2.4.0-x86_64-linux.tar.gz: The requested URL returned error: 404 Not Found
     Trying next mirror...
     Could not download https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release/6.0.4/rubyext-ruby-2.4.0-x86_64-linux.tar.gz: The requested URL returned error: 403 Forbidden
 [passenger_native_support.so] will not be used (can't compile or download) 
  --> Passenger will still operate normally.
Error: The application encountered the following error: cannot load such file -- bundler/setup (LoadError)
    /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /home/ubuntu/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:363:in `activate_gem'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:221:in `block in run_load_path_setup_code'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:527:in `running_bundler'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:220:in `run_load_path_setup_code'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:91:in `preload_app'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
    /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:380:in `run_block_and_record_step_progress'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in `<module:App>'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
    /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'

Does anybody has any idea?有人有任何想法吗?

passenger is trying to download a file that does not exist.乘客正在尝试下载不存在的文件。

try with ruby 2.4.6 since that version is listed on the github release page尝试使用 ruby​​ 2.4.6,因为该版本已在 github 发布页面上列出

https://github.com/phusion/passenger/releases/ https://github.com/phusion/passenger/releases/

Most probably the point is in that you're setting up and testing rvm/ruby under ubuntu user, but nginx server is running under some other user (which does not have rvm configured, at least in the session in which the daemon runs)最有可能的一点是,您正在ubuntu用户下设置和测试 rvm/ruby,但 nginx 服务器正在其他用户下运行(该用户没有配置 rvm,至少在守护进程运行的会话中)

RVM has ability to create a wrapper, that will set correct paths and gemset (if needed): RVM 能够创建一个包装器,它将设置正确的路径和 gemset(如果需要):

rvm alias create ruby_for_my_app ruby-2.4.0@myrepo

and then use /home/ubuntu/.rvm/wrappers/ruby_for_my_app/ruby in passenger_ruby nginx config directive (remember to reload it after changing)然后在passenger_ruby nginx 配置指令中使用/home/ubuntu/.rvm/wrappers/ruby_for_my_app/ruby (记得更改后重新加载)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM