nginx plus embedded ruby - how?
Can someone tell me the best way to serve up embedded ruby [ie. using .erb or .rhtml] using nginx?
I was hoping there'd be some similar ruby-esque equivlaent to PHP-FPM, which I'm using to serve up my PHP files via nginx [as described here:
I think [but I'm not completely sure!] that using phusion passenger [
Anyone able to help?
I recommend using Rack to host your sites directly, or using some very thin abstraction on top of Rack (i.e. Sinatra). Then you can use Phusion Passenger to host the Rack application. Phusion Passenger has two options:
1.) Compile a module directly into nginx. This works great if you're doing a source-based install of nginx. The downside here, though, is that you're locked into a single version of Ruby, so tools like RVM are basically useless.
2.) Run the standalone passenger webserver (which is actually a mini nginx install that listens on a local socket). You can do this by running "gem install passenger", and then "passenger start" within your application's main directory. The advantage here is that you can use whatever version of Ruby you want, and it plays very nicely with RVM's gemsets. The downside is obviously that you have another mini nginx install, but I really haven't ever encountered a problem with this setup. Nginx uses so little memory and CPU that it really is negligible in my opinion.
1.) Make your application Rack compliant (Sinatra is awesome for this!)
2.) Use Phusion Passenger to serve your app on a local TCP or Unix socket (other options for this are unicorn or thin, but most people tend to prefer passenger).
3.) If you decided to use passenger standalone, configure your main nginx install to proxy_pass requests to the passenger standalone. If you compiled passenger support directly into your main nginx install, this step is not required.
My recommendation: use passenger standalone over a Unix socket. I run a few Rails sites on my 512 with no problems.