在全新安装的Nginx/Passenger上运行Rails应用会导致错误“没有此类文件可加载-捆绑程序/设置(LoadError)". [英] running a Rails app on a fresh installation of Nginx/Passenger causes error "no such file to load -- bundler/setup (LoadError)"

查看:119
本文介绍了在全新安装的Nginx/Passenger上运行Rails应用会导致错误“没有此类文件可加载-捆绑程序/设置(LoadError)".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行Ubuntu 12.04的VPS.我已经按照这些安装了Nginx和Passenger. 这些说明,并且按照说明,我添加了到文件/etc/nginx/nginx.confhttp块的以下行:

I have a VPS running Ubuntu 12.04. I've installed Nginx and Passenger on it by following these and these instructions, and as per the instructions, I've added to the http block of file /etc/nginx/nginx.conf the following lines:

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;

和以下代码段(在其中,我用www.example.com替换了实际的域名):

and the following block (where I've replaced the actual domain name by www.example.com):

server {
    listen 80;
    server_name www.example.com;
    root /srv/rails/myapp/public;
    passenger_enabled on;
}

Rails应用程序位于目录/srv/rails/myapp/中,该目录也是Git项目目录.该目录及其所有内容均由用户rails拥有.我已经将该目录设置为可写世界,并且以用户rails的身份在其中运行以下命令:

The Rails application lives in directory /srv/rails/myapp/, which is also a Git project directory. The directory and all its contents are owned by user rails. I've made the directory world-writeable, and, as user rails, run the following commands in it:

git pull
gem install bundler
bundle install
rake db:migrate
RAILS_ENV=production bundle exec rake assets:precompile

此后,在开发模式下运行应用程序成功:当我命令rails s并打开 http://www.example.com:3000 ,该应用程序可以正常运行.

After this, running the application in development mode succeeds: when I command rails s, and open http://www.example.com:3000, the application works fine.

但是,完成上述所有操作并命令sudo service nginx restart之后,打开 http://www.example.com 会显示一个乘客错误"屏幕,其中显示:

However, after doing the all the above, and commanding sudo service nginx restart, opening http://www.example.com yields a Passenger error screen, which says:

no such file to load -- bundler/setup (LoadError)
  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:245:in `run_load_path_setup_code'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:348:in `running_bundler'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:243:in `run_load_path_setup_code'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:158

下面有很多调试输出,我不确定其中哪个有用,但这是摘录:

There's lots of debug output below that, and I'm not sure which of it is useful, but here's an excerpt:

Application root

    /srv/rails/myapp

Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV)

    production

Ruby interpreter command

    /usr/bin/ruby

User and groups

    uid=1001(rails) gid=1002(rails) groups=1002(rails)

Environment variables

    SHELL = /bin/bash
    PASSENGER_DEBUG_DIR = /tmp/passenger.spawn-debug.XXXX2fPMPM
    USER = rails
    PWD = /srv/rails/myapp
    SHLVL = 0
    HOME = /home/rails
    LOGNAME = rails
    SERVER_SOFTWARE = nginx/1.4.6
    IN_PASSENGER = 1
    PYTHONUNBUFFERED = 1
    NODE_PATH = /usr/share/passenger/node
    RAILS_ENV = production
    RACK_ENV = production
    WSGI_ENV = production
    NODE_ENV = production
    PASSENGER_APP_ENV = production
    SERVER_PROTOCOL = HTTP/1.1
    SCGI = 1
    DOCUMENT_ROOT = /srv/rails/myapp/public
    QUERY_STRING =
    SERVER_NAME = www.example.com
    REMOTE_PORT = 49316
    REMOTE_ADDR = [redacted]
    SERVER_PORT = 80
    REQUEST_METHOD = GET
    SERVER_ADDR = [redacted]
    REQUEST_URI = /

...

General Ruby interpreter information

    RUBY_VERSION = 1.8.7
    RUBY_PLATFORM = x86_64-linux
    RUBY_ENGINE = nil
    RubyGems version = 1.8.15

该应用程序使用Ruby v2.0.0p353,而Passenger似乎使用v1.8.7;我不确定这是否与此问题有关. (该应用程序使用的Ruby位于/home/rails/.rvm/rubies/ruby-2.0.0-p353/中.)

The application uses Ruby v2.0.0p353 while Passenger seems to use v1.8.7; I'm not sure if that has anything to do with this problem. (The Ruby used by the app lives in /home/rails/.rvm/rubies/ruby-2.0.0-p353/.)

我还搜索了其他乘客输出此错误的问题,但到目前为止我没有尝试解决此问题.

I've searched for other problems where Passengers outputs this error, but nothing I've tried so far fixes the problem.

推荐答案

尝试各种方法后,我放弃了从Debian软件包安装nginx的工作.我删除了它,还删除了我的红宝石和RVM,然后按照这些指示.本文建议如何使用乘客gem随附的passenger-install-nginx-module命令安装nginx.它检查所有依赖项,如果可以继续,则下载并编译nginx.默认情况下,它安装在/opt/nginx/中.

After trying various things, I gave up on having nginx installed from Debian packages. I removed it, and also removed my rubies and RVM, then reinstalled everything, following these directions. The article advises how to install nginx using the passenger-install-nginx-module command that comes with the passenger gem. It checks all dependencies, and if it can proceed, downloads and compiles nginx. By default, it's installed in /opt/nginx/.

这不能立即生效.我还必须创建一个nginx启动脚本;说明此处.此外,我必须编辑/opt/nginx/conf/nginx.conf文件以添加对我的应用程序的引用,还必须注释掉location /块.完成所有这些操作后,并命令sudo service nginx restart,站点已启动.

This did not work immediately. I also had to create an nginx startup script; instructions here. Furthermore, I had to edit the /opt/nginx/conf/nginx.conf file to add a reference to my application, and also had to comment out the location / block. After all this, and commanding sudo service nginx restart, the site is up.

这篇关于在全新安装的Nginx/Passenger上运行Rails应用会导致错误“没有此类文件可加载-捆绑程序/设置(LoadError)".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆