Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Mar 22, 2011 11:50 am 
Offline
Junior Member
User avatar

Joined: Sat Mar 13, 2010 2:50 pm
Posts: 33
Location: The Intarwebs
Twitter: stiobhart
Apologies if this is a dumb question, but I'm a recent convert to nginx, after many years hosting my sites using Apache and I'm still finding my way around:

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: http://interfacelab.com/nginx-php-fpm-apc-awesome ], but I'm not having any luck.

I *think* [but I'm not completely sure!] that using phusion passenger [ http://www.modrails.com ], to build a complete nginx/RoR application serving stack, might allow me to just use it to serve embedded ruby, but it seems like a bit of overkill, when all I want to do is use ruby for a bit of form-validation and the occasional bit of dynamic text generation inside HTML.

Anyone able to help?

_________________
**************************
Mental Diarrhoea
**************************


Top
   
 Post subject:
PostPosted: Fri Mar 25, 2011 10:06 am 
Offline
Senior Newbie

Joined: Sun Aug 22, 2010 12:57 pm
Posts: 19
So what it comes down to is the need to pass requests off to your ruby site. To do this, the ruby site will need to run on a local address and port, and then you can proxy_pass requests to the ruby site.

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.

TLDR:

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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group