nginx+passenger 和 Gemfile 在非公共位置
nginx+passenger and Gemfile in non-common location
我们有一个使用非标准 rails Gem 文件位置的应用程序。它与 Nginx+unicorn 一起工作得很好,但我很难让它与 Nginx+Passenger 一起工作。将 root
参数设置为 Rails public 文件夹后,我注意到它没有在父文件夹中加载其他 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 是在 Gem 文件中定义的 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"
我不再收到未找到宝石的错误,但它不会使用 Rails 进行路由。有什么想法吗?
版本:
- Ubuntu-12.04
- Phusion Passenger 版本 5.0.8
- nginx/1.6.3
- rvm 1.25.28
- ruby 1.9.3p327
- Rails 3.2.18
尝试指定 Passenger 的 BUNDLE_GEMFILE variable use passenger_env_var 指令。似乎在这种情况下,Bundler 会知道您的 Gemfile 所在的位置。
我们有一个使用非标准 rails Gem 文件位置的应用程序。它与 Nginx+unicorn 一起工作得很好,但我很难让它与 Nginx+Passenger 一起工作。将 root
参数设置为 Rails public 文件夹后,我注意到它没有在父文件夹中加载其他 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 是在 Gem 文件中定义的 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"
我不再收到未找到宝石的错误,但它不会使用 Rails 进行路由。有什么想法吗?
版本:
- Ubuntu-12.04
- Phusion Passenger 版本 5.0.8
- nginx/1.6.3
- rvm 1.25.28
- ruby 1.9.3p327
- Rails 3.2.18
尝试指定 Passenger 的 BUNDLE_GEMFILE variable use passenger_env_var 指令。似乎在这种情况下,Bundler 会知道您的 Gemfile 所在的位置。