Passenger Standalone,不需要HTTP Server?
使用 Passenger Standalone(由 Nginx 核心提供支持)是否意味着我们根本不需要像 Apache 或 Nginx 这样面向 Web 的 HTTP 服务器?
Does using Passenger Standalone (powered by Nginx core) imply that we do not need the web facing HTTP servers like Apache or Nginx at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短的回答是“是”,这确实是它的工作原理。基本上,passenger Standalone 允许您通过
passenger start
运行应用程序,并且它在幕后使用 nginx 来实际服务 Rails 请求。然而,将乘客独立运行作为唯一的网络服务器存在一个大问题。如果您想运行多个基于 ruby 的网站,则必须在单独的端口上运行它们,因为没有办法通过乘客独立代理对单个应用程序的请求。
在我的环境中,我需要使用多个不同版本的 ruby(不仅仅是不同版本的 Rails)来运行多个站点。例如,我有一个站点运行带有 Ruby Enterprise Edition 的 Rails 2.3.x,另一个站点运行 Rails 3.0.x(运行 Ruby 1.9.2)。我使用 Passenger Standalone 和单独的 Nginx 代理来解决这个问题:
每个网站都运行 Passenger Standalone,我已将其配置为侦听本地 UNIX 套接字。我使用 RVM 来为我加载 ruby 版本,因此我的
passenger start
命令有点长,但看起来像这样:cd /path/to/my/app; rvm使用ree-1.8.7-2011.03@gemset;导出 GEM_HOME=/usr/local/rvm/gems/ree-1.8.7-2011.03@gemset; /usr/local/rvm/gems/ree-1.8.7-2011.03@gemset/bin/passenger start -d -S /tmp/mysite.com.sock -e 生产 --pid-file /path/to/my/应用程序/共享/pids/passenger.pid
现在我的应用程序正在运行并侦听
/tmp/mysite.com.sock
,我还有另一个在端口 80 上运行的 Nginx 实例,仅使用简单的 proxy_pass 规则分别向每个站点发送请求。抱歉,这篇文章很长,也许信息有点太多了……但我发现这个组合效果非常好,并且我编写了一些漂亮的
init.d
样式脚本来启动我的个人乘客独立应用程序。 Nginx 内存使用量低得惊人,运行 3 个实例(每个站点 1 个,端口 80 上 1 个)实际上并不需要任何成本。希望这有帮助!
The short answer is "yes" that is indeed how it works. Basically passenger standalone allows you to run your application via
passenger start
, and it uses nginx behind the scenes to actually serve rails requests.There is one big problem with running passenger standalone as your only webserver, however. If you want to run more than one ruby-based website, you'll have to run them each on separate ports, since there's no way to proxy requests to individual applications with passenger standalone by itself.
In my environment, I needed to run multiple sites using multiple different versions of ruby (not just different versions of rails). For example I have one site running Rails 2.3.x with Ruby Enterprise Edition, and another site running Rails 3.0.x running Ruby 1.9.2. I used passenger standalone with a separate Nginx proxy to solve this problem:
Each website runs passenger standalone, which I have configured to listen on a local UNIX socket. I use RVM to take care of loading my ruby version for me, so my
passenger start
command is a bit lengthy, but it looks like this:cd /path/to/my/app; rvm use ree-1.8.7-2011.03@gemset; export GEM_HOME=/usr/local/rvm/gems/ree-1.8.7-2011.03@gemset; /usr/local/rvm/gems/ree-1.8.7-2011.03@gemset/bin/passenger start -d -S /tmp/mysite.com.sock -e production --pid-file /path/to/my/app/shared/pids/passenger.pid
Now that my app is running and listening at
/tmp/mysite.com.sock
, I have another Nginx instance that runs on port 80 that just uses simple proxy_pass rules to send requests to each site individually.Sorry for the long post, and maybe it's a bit too much information... but I've found that this combo works really well, and I've written some nice
init.d
style scripts to launch my individual passenger standalone apps. Nginx memory usage is so amazingly low that it doesn't really cost anything to run 3 instances of it (1 for each site, and 1 on port 80).Hope this helps!
据我所知( http://www.modrails.com/documentation/ Users%20guide%20Standalone.html ) “Passenger Standalone”本身就是一个网络服务器。
As far as I can read ( http://www.modrails.com/documentation/Users%20guide%20Standalone.html ) "Passenger Standalone" is itself a webserver.