PDA

View Full Version : RubyOnRails Tips


IainK
03-31-2007, 09:46 AM
Hey all,
I've been testing out 3 ruby configurations on my myriadnetwork VDS (with cPanel) before making a choice.

RubyOnRails into apache with mod_ruby
RubyOnRails into apache with mod_fastcgi
RubyOnRails into apache with mod_proxy

I'm not new to Ruby, and have tested all these configurations the last time I rolled out a server, but I thought since it was all spanky new versions and probably a far better host I would re-anaylse what's best.

Once again I found that mod_ruby lacks performance and mod_fastcgi on apache is unstable and can leave processes running/eventually not even accept connections.

When using mod_proxy I did briefly consider the horrible lighttpd, but it was quickly dismissed for the fast, light ruby based server mongrel.

So from mongrel running only on 127.0.0.1 and an assigned port number my sites are using mod_proxy into Apache. I have set / to proxy on my main site and all appears to be working great (and faster than other methods). e.g. @ www.uxua.eu (http://www.uxua.eu)

One thing I will note is if you install the newest version of Ruby make sure you have the 0.9.2 version of gems. For some reason anything else will give errors when trying to run any gem in a ruby app!!

Edit. It's probably best to note that the reason ruby is always going into Apache in this is because it's on a cPanel server.

Ryan
03-31-2007, 11:14 AM
Great info here! Thanks for getting this writeup together and posting it for everyone else. I'll be sure to point customers to it if they have any questions regarding ruby and its best route.

Ryan

IainK
03-31-2007, 11:56 AM
No problem - I found there are literally 100s of guides on how to install but lacking information on what the problems are with each method.

Although the above is brief the jist is mongrel (or even lighttpd if you must) with mod_proxy is the best way.

On top of this the setup is extremely easy! Installing mongrel is as easy as gem install mongrel and as for mod_proxy just run the following in shell as root cd /home/cpapachebuild/buildapache/apache_1.3.37/src/modules/proxy/
/usr/local/apache/bin/apxs -i -c *.c

then open your /etc/httpd/conf/httpd.conf file and locate the LoadModule lines. Scroll to the bottom and add LoadModule proxy_module libexec/mod_proxy.so below you will find AddModule lines, once again scroll to the bottom and add AddModule mod_proxy.c Don't forget to run /sbin/service httpd restart to restart apache. That's mod_proxy installed!

Then it's just a matter of adding the following to the end (the bottom, but before </Virtu...) of each <VirtualHost> container ProxyPass /ruby http://127.0.0.1:PORT/
ProxyPassReverse /ruby http://127.0.0.1:PORT/

You can then access the site by http://www.yoursite.com/ruby replacing yoursite.com with the site in ServerAlias in the VirtualHost.

If anyone wants any help with this just drop me a PM.