【问题标题】:$GEM_HOME and $GEM_PATH are wrongly set in Passenger$GEM_HOME 和 $GEM_PATH 在乘客中设置错误
【发布时间】:2017-11-19 06:13:05
【问题描述】:

我正在尝试在 docker 容器中使用 Passenger(v5.1.4)+Nginx 设置 rails(v4.2.6) 应用程序。 我使用官方 ruby​​ 2.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
  • 宝石安装在/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:

乘客无法找到应用程序 gem,因为 GEM_HOME 和 GEM_PATH 设置错误

我尝试在 docker-entrypoint 中手动设置环境变量 GEM_HOMEGEM_PATH 以更正 gem 路径,即 /usr/local/bundle。但是它不起作用。

我怎样才能让乘客使用正确的宝石。

注意:我没有使用rvm

提前致谢

【问题讨论】:

    标签: ruby nginx docker rubygems passenger


    【解决方案1】:

    这个问题的原因是user_sandboxing by passenger

    由于我的应用程序目录归根用户所有,并且我没有在 nginx 中配置 passenger_default_user,因此乘客以用户 nobody 和组 nogroup 的身份盯着应用程序

    我通过将我的应用程序目录的所有者更改为非 root 用户来解决此问题。

    注意:我还必须使用 rvm 而不是 ruby​​:2.3.1 基础映像。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-22
      • 1970-01-01
      • 1970-01-01
      • 2014-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-01
      相关资源
      最近更新 更多