问题描述
我一直在研究这一问题,并在各处发现了类似问题的参考,但没有一个导致解决方案.我已经安装了passenger(2.2.11)和nginx(0.7.64),当我启动并单击Rails URL时,出现错误页面,通知我加载错误:
没有要加载的文件-/path/to/app/config/environment
从我在网上发现的内容来看,这似乎是某种用户/权限错误,但是我尝试了所有合理的修复方法:我确保/config/environment.rb不属于root. ,但由webapp用户使用.我试过设置passenger_default_user,我试过将passenger_user_switching关闭.我什至尝试设置nginx用户,尽管那没什么大不了.我得到了一些不同的结果,但实际上没有任何效果.我希望有人可以对此进行设置和权限的神奇组合.我可能会尝试回退到早期版本的乘客",因为我以前从未遇到过此问题.自从我设置乘客"以来已经有一段时间了.
谢谢您的建议.
我偶然发现的答案,请参见下文.
自然地,我只是把问题贴到了答案上.为了向搜索此问题的其他任何人提供信息,我将在此处发布一些详细信息.
nginx.conf
中的相关行:
user www-data; # in order to have nginx not run as root
passenger_default_user www-data; # likewise for passenger
root /opt/foo/app/current/public;
这时的关键是确保应用程序文件归www-data拥有,尤其是config/environment.rb
,这是因为显然Passenger会查看其所有者来确定运行者.这可能意味着passenger_default_user
条目是不相关的?但无论如何,最好将其作为意图的文档.
最后,请确保您的应用程序的所有父目录都可以通过www-data
进行访问-在我的情况下,系统默认设置已留下目录0700
,我错过了.
I've been researching this one and found references to similar problems here and there, but none of them has led to a solution yet. I've installed passenger (2.2.11) and nginx (0.7.64) and when I start things up and hit a Rails URL, I get an error page informing me of a load error:
no such file to load -- /path/to/app/config/environment
From what I've found online this appears to be some sort of a user/permissions error, but I've tried all the logical fixes: I've made sure that /config/environment.rb is not owned by root, but by a webapp user. I've tried setting passenger_default_user, I've tried setting passenger_user_switching off. I've even tried setting the nginx user, though that shouldn't matter much. I've gotten some differing results, but nothing's actually worked. I'm hoping someone may have the magical combination of settings and permissions for this. I may try backing down to an earlier version of Passenger, because I've never had this issue before; it's been a little while since I set up Passenger though.
Thanks for any suggestions.
EDITED: See below for the answer I stumbled on.
Naturally, it just took me posting the question to stumble onto the answer. In order to provide info for anyone else searching on this problem, I'll post some details here.
The relevant lines from the nginx.conf
:
user www-data; # in order to have nginx not run as root
passenger_default_user www-data; # likewise for passenger
root /opt/foo/app/current/public;
The key at this point is to make sure that the application files are owned by www-data, in particular config/environment.rb
because apparently Passenger looks at its owner to determine who to run as. This might mean that the passenger_default_user
entry is irrelevant? But it's good to have it there as documentation of intent anyway, perhaps.
Finally, make sure that the parent directories of your app are all reachable by www-data
-- in my case the system default setup had left a directory 0700
, which I'd missed.
这篇关于乘客问题:“没有此类文件可加载" -/配置/环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!