我应该将 RVM 安装为多用户吗?

发布于 2024-11-09 23:53:45 字数 750 浏览 2 评论 0原文

我把自己描绘成一个有点烦人的角落。

我开始使用 RVM,并且我的一个应用程序现在愉快地位于它自己的 Ruby 1.8.7@appname gemset 中。我可以从头开始制作 gemset,并执行 bundle install 来安装所有 gem。一切都很好。

因此,在托管应用程序的服务器上,在带有乘客的 nginx 下,我在拥有应用程序文件夹的用户“deploy”下安装了 RVM。然后我用bundle install安装了所有的gems。然后,我更改了 nginx 配置以指向应用程序的新版本,即在 RVM 下运行的版本。砰!,乘客开始抱怨宝石不存在。

我认为问题在于 nginx 以 root 身份运行,而它没有定义 RVM。 “没问题”我想,我会将应用程序的 RVM 设置为系统默认值。因此,我切换到 root,然后执行 rvm --default 1.8.7@appname。我得到:

rvm: command not found

回来了,所以,看起来 RVM 是仅为“部署”用户安装的。我想我应该按照 RVM 的安装文档为所有用户安装它。

我必须从头开始吗? IE,我应该切换回“部署”用户,卸载 RVM 及其所有痕迹,然后以 root 身份重新安装吗?或者我可以在正确的 RVM 中运行 nginx/passenger 吗?

I painted myself into a bit of an annoying corner.

I started using RVM and have one of my apps now sitting happily in its own Ruby 1.8.7@appname gemset. I can make the gemset from scratch and do bundle install to install all the gems.All is good.

So, on the server where the app is hosted, under nginx with passenger, I installed RVM under the user "deploy" that owns the app folder. Then I installed all the gems with bundle install. Then, I changed the nginx config to point to the new version of the app, the one that runs under RVM. BAM!, Passenger starts complaining about the gems not being present.

I think the problem is that nginx runs as root, which doesn't have RVM defined. "No problem" I thought, I'll set the app's RVM to be the system default. So, I switched to root, then did rvm --default 1.8.7@appname. I got:

rvm: command not found

back, so, it looks like RVM was only installed for the "deploy" user. I guess i should have installed it for all users, following RVM's install document.

Do I have to start again from scratch? I.E., should I switch back to the "deploy" user, uninstall RVM and all traces of it, then reinstall it as root? Or can I run nginx/passenger in the right RVM?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

筑梦 2024-11-16 23:53:45

前言:我不是当前的乘客用户。所以接下来的事情只是想法和回忆。

首先:如果我没记错的话,只有 nginx 的主进程明确以 root 身份运行,但子进程在用户/组 ID 下运行,您可以在 nginx 配置中设置这些 ID。 (如果你关心安全,你应该这样做!)

不知道这是否会影响乘客模式 - 会说,它应该,因为主进程仅用于跨越将完成实际工作的工作进程。也不能说,乘客的辅助进程是否以与工作人员相同的用户权限运行。 (它应该,出于与第一段中相同的原因。)

您应该在 nginx 中使用 passenger_default_user 设置。它应该避免您的用户麻烦。

其次尝试https://rvm.beginrescueend.com/integration/下的提示Passenger/

它们可能会很有帮助,尤其是在用户安装 RVM 的情况下。

请仔细阅读注意事项疑难解答常见问题解答部分!

我的第三点:我更喜欢在生产系统上安装 RVM 系统。因此,您可以为不同的(系统/服务)用户构建不同的设置,而不会遇到用户范围的问题。

最后但并非最不重要的一点:我过去没有在 RVM-passenger-nginx 设置方面获得过如此好的体验。另外,我不喜欢超载的网络服务器/负载均衡器,因此永远不会再使用 nginx 乘客模块。保留不属于它的东西。

另外请记住,passenger-nginx mod 取消了使用不同 ruby​​ 和 ruby​​ 版本与 nginx+passenger 的功能。可以说在这种情况下使用 RVM 意义不大。我更喜欢仅使用 nginx 作为代理,并让 unicorn/thin/whatever-else 来完成网络服务器工作。

结论

我想说,这不是 root 用户的问题。我认为您的设置中缺少某些内容或配置错误。

回答你的最后一个问题:不,我认为没有必要安装系统 rvm,是的,应该可以使用正确的(用户)rvm 在 nginx 中运行乘客。

Preface: I'm not a current passenger user. So following stuff are only thoughts and memories.

Firstly: If I remember correctly than only the main process of nginx runs definitly as root, but the child processes runs under user/group ID which you can set up in the nginx config. (And you should do this if you care for security!)

Don't know if this affect the passenger mod - would say, it should, because the main process is only for spanning up the worker processes which will do the real job. Also can't say, if the helper process for passenger runs with same user rights than the worker. (It should, for same reason like in first paragraph.)

There is a passenger_default_user setting you should use in nginx. It should avoid your user troubles.

Secondly try the tips under https://rvm.beginrescueend.com/integration/passenger/

They might be helpful especially in case of user installs of RVM.

Please read the parts Notes, Troubleshooting and FAQ carefully!

And my third point: I would prefer a system install of RVM on the production system. So you have the possibility to build different setups for different (system/service) users without having troubles of user scopes.

Last but not least: I haven't made so good experiences with a RVM-passenger-nginx setup in past. Also I'm not a friend of overloaded webservers/loadbalancers and so would never use the nginx passenger module any more. Keep out stuff which doesn't belong to it.

Alos keep in mind that the passenger-nginx mod kills the capability to use different rubies and ruby versions with nginx+passenger. Would say in this cases it makes less sense to use RVM. I prefer to use nginx as proxy only and let do the webserver job by unicorn/thin/whatever-else.

Conclusion

I would say, it's not a problem with the root user. I think, something in your setup is missing or misconfigured.

To answer your last questions: No, I think it's not necessary to install a system rvm and yes, it should be possible to run passenger in nginx with correct (user) rvm.

-残月青衣踏尘吟 2024-11-16 23:53:45

默认情况下,Passenger 在与文件 config/environment.rb 所有者相同的 UID 下运行 Rails 应用程序,因此您可以将应用程序保留在 deploy 用户下。请参阅 Passenger 文档中的用户切换部分。

此外,在 ngnix 配置中设置 passenger_ruby 变量以指向 RVM ruby​​ 二进制文件也很重要,例如:

passenger_ruby /home/deploy/.rvm/bin/passenger_ruby;

请参阅 RVM Passenger 集成文档 了解更多详细信息。

By default Passenger runs Rails application under same UID as the owner of the file config/environment.rb, so you could keep your application under deploy user. See section User switching in Passenger documentation.

Also, it is critical to set passenger_ruby variable in ngnix config to point to RVM ruby binary, for example:

passenger_ruby /home/deploy/.rvm/bin/passenger_ruby;

See RVM Passenger integration documentation for additional details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文