gpt4 book ai didi

ruby - $ GEM_HOME和$ GEM_PATH在旅客中设置错误

转载 作者:行者123 更新时间:2023-12-02 19:36:25 26 4
gpt4 key购买 nike

我正在尝试在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;

更多内容:
  • /usr/local/bin/ruby上存在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:

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

    Taken from passenger error page

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

    我如何让乘客使用正确的 gem 。

    注意:我没有使用 rvm
    提前致谢

    最佳答案

    出现此问题的原因是user_sandboxing by passenger

    由于我的应用程序目录归root所有,并且我没有在nginx中配置passenger_default_user,所以passenger盯着应用程序作为用户nobody和组nogroup
    我通过将应用目录的所有者更改为非root用户来解决此问题。

    注意:另外我还必须使用rvm而不是ruby:2.3.1基本镜像。

    关于ruby - $ GEM_HOME和$ GEM_PATH在旅客中设置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44589721/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com