Passenger中错误地设置了$ GEM_HOME和$ GEM_PATH
我正在尝试在Docker容器中使用Passenger(v5.1.4)+ Nginx设置一个rails(v4.2.6)应用程序。 我使用官方ruby2.3.1作为基础的形象。
以下是我的网站nginx文件
server { server_name example.local; listen 4000; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /www/app/public; passenger_ruby /usr/local/bin/ruby; try_files $uri @passenger; location @passenger { passenger_enabled on; rails_env development; } ... } passenger_pre_start http://0.0.0.0:4000/status;
更多上下文:
- Ruby二进制文件存在于
/usr/local/bin/ruby
- gem安装在
/usr/local/bundle
但是当我启动nginx服务时,出现以下错误
It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run: bundle install If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:
乘客无法find应用程序的gem,因为,GEM_HOME和GEM_PATH设置错误
我已经尝试在GEM_PATH
-entrypoint中手动设置环境variablesGEM_HOME
和GEM_PATH
,以更正gempath,即/usr/local/bundle
。 然而它不工作。
我怎样才能让乘客使用正确的gem。
注意:我没有使用rvm
提前致谢
这个问题的原因是乘客user_sandboxing
由于我的应用程序目录由root拥有,并且我没有在nginx中configurationpassenger_default_user,所以乘客正在将应用程序视为用户nobody
和组nogroup
我通过将我的app目录的所有者更改为非root用户来解决此问题。
注意:我也必须使用rvm而不是ruby:2.3.1基本映像。