Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passenger Standalone, no need of HTTP Server?

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?

like image 652
Pratik Khadloya Avatar asked Jun 15 '11 19:06

Pratik Khadloya


People also ask

Is passenger a web server?

What is Passenger®? Phusion Passenger® is an open source web application server. It handles HTTP requests, manages processes and resources, and enables administration, monitoring and problem diagnosis.

What is Passenger web?

Passenger® is an app server that runs and automanages your web apps with ease. Also improves security, reliability and scalability.

What is passenger in Apache?

The Passenger Apache module registers Passenger-specific configuration options inside Apache. You, the administrator, configure Passenger by adding Passenger-specific configuration options to the Apache configuration file. Restart or reload Apache to apply any configuration changes.

What is passenger nginx?

The Passenger Nginx module registers Passenger-specific configuration options inside Nginx. You, the administrator, configure Passenger by adding Passenger-specific configuration options to the Nginx configuration file. Restart or reload Nginx to apply any configuration changes.


1 Answers

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!

like image 66
Scott Anderson Avatar answered Sep 19 '22 22:09

Scott Anderson