【问题标题】:nginx+passenger and Gemfile in non-common locationnginx+passenger 和 Gemfile 在非公共位置
【发布时间】:2015-08-10 07:12:14
【问题描述】:

我们有一个使用非标准 Rails Gemfile 位置的应用程序。它与 Nginx+unicorn 一起工作得很好,但我很难让它与 Nginx+Passenger 一起工作。在将 root 参数设置为 Rails 公用文件夹后,我注意到它没有在父文件夹中加载其他 ruby​​ 依赖项。我尝试使用 root、passenger_app_root、passenger_document_root 但没有锁定。有什么想法吗?以下是详细信息。

文件结构:

symphony     <--------- Root (has the Gemfile)
├── bin/
├── common/
├── config
├── lib/    <--------- Ruby dependencies        
├── log/
├── reports/
├── schedulers/
├── timeout_daemon/
├── spec/
├── tools/
├── Gemfile        <--- The Gemfile
├── Gemfile.lock
└── manager        <--- Regular Rails app folder
    ├── cache/
    ├── config/
    ├── db/
    ├── lib/
    ├── log/
    ├── public/   <--- Public folder
    ├── features/
    ├── spec/
    ├── test/
    ├── vendor/
    ├── tmp/
    ├── script
    ├── config.ru
    ├── README
    ├── Rakefile
    └── app/      <--- Rails stuff
        ├── assets
        ├── controllers
        ├── decorators
        ├── helpers
        ├── mailers
        ├── models
        ├── sweepers
        ├── validators
        ├── views
        └── widgets              

Nginx.conf

include nginx.core.conf;

http {

  include nginx.http.conf;

  passenger_ruby /home/blueserver/.rvm/gems/ruby-1.9.3-p327-turbo@symphony/wrappers/ruby;
  passenger_root /home/blueserver/.rvm/gems/ruby-1.9.3-p327-turbo@symphony/gems/passenger-5.0.8;

  server {
    listen 3000 ssl deferred;

    # redirects HTTP to HTTPS
    error_page 497  https://$host:$server_port$request_uri;

    # SSL Configuration
    ssl_certificate /certs/ssl_cert_and_chain;
    ssl_certificate_key /keys/ssl_key;
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1; # disabled the SSLv23 (POODLE)

    # passenger settings
    rails_env production;

    # shared locations nginx config
    root /home/blueserver/symphony/manager/public;

    passenger_enabled on;

    error_page 500 502 503 504 /500.html;

    # provide paths for the static content
    location ~* ^/assets {
      expires max;
      access_log off;
      gzip_static on;
      add_header Cache-Control public;
    }
  }
}

我收到以下错误:

Message from application: undefined method `acts_as_list' for #<Class:0x994c538> (NoMethodError)

(此处的完整错误消息:http://pastebin.com/sgxFn8pu

acts_as_list 是 Gemfile 中定义的 Gem。

我尝试过 root、passenger_app_root、passenger_document_root 等不同的配置...

如果:

root /home/blueserver/symphony/manager/public;
passenger_app_root /home/blueserver/symphony;

然后得到错误:

2015/05/28 00:27:59 [error] 29595#0: *78 directory index of "/home/blueserver/symphony/manager/public/" is forbidden, client: 192.168.101.61, server: , request: "GET / HTTP/1.1", host: "192.168.101.45:3000"

我不再收到 gems not found 错误,但它不能通过 Rails 路由。请问有什么想法吗?

版本

  • Ubuntu-12.04
  • Phusion 乘客版本 5.0.8
  • nginx/1.6.3
  • rvm 1.25.28
  • 红宝石 1.9.3p327
  • Rails 3.2.18

【问题讨论】:

    标签: ruby-on-rails nginx rvm passenger gemfile


    【解决方案1】:

    尝试指定BUNDLE_GEMFILE 变量使用Passenger 的passenger_env_var 指令。在这种情况下,Bundler 似乎会知道您的 Gemfile 所在的位置。

    【讨论】:

    • 非常感谢! passenger_env_var BUNDLE_GEMFILE /home/blueserver/symphony/Gemfile; 完成了这项工作:)
    猜你喜欢
    • 2012-05-27
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    • 2012-07-10
    • 2012-04-14
    相关资源
    最近更新 更多