开发者

Should I have installed RVM as multi-user?

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 t开发者_JS百科o 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜