我无法通过Nginx / Ubuntu上的Phusion Passenger在生产环境中运行Rails应用程序.根据docs,环境由Nginx.conf中的rails_env选项控制…但它在我们的盒子上以开发模式运行,无论我们是否指定’rails_env production;’或者将其遗漏(默认为生产).
其他说明:
> Linux环境变量
RAILS_ENV也将投入生产.
>我们可以使用生产模式运行
‘script / server -e production’,所以它
似乎不是Ruby的情况
代码覆盖环境.
有任何想法吗?
完整的Nginx.conf:
worker_processes 1;
pid /var/run/Nginx.pid;
events {
worker_connections 1024;
}
http {
passenger_root /var/lib/gems/1.8/gems/passenger-2.2.7;
passenger_ruby /usr/bin/ruby1.8;
include mime.types;
default_type application/octet-stream;
access_log /var/log/Nginx/access.log;
error_log /var/log/Nginx/error.log;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+RSS text/javascript;
gzip_buffers 16 8k;
server {
listen 80;
server_name bar.foo.com;
root /home/foo/dev/bar/public;
passenger_enabled on;
rails_env production;
}
}
最佳答案
解决方法发现于http://groups.google.com/group/phusion-passenger/browse_thread/thread/f91cd54bd379ad26/0a510133a080daac
原文链接:https://www.f2er.com/nginx/434375.html添加到config.ru:
ENV['RAILS_ENV'] = ENV['RACK_ENV'] if !ENV['RAILS_ENV'] && ENV['RACK_ENV']