« Setting up a Ruby on Rails server - Part 3 - Installing MySQL | Home | Setting up a Ruby on Rails server - Part 5 - Java - Tomcat - Ant »

Setting up a Ruby on Rails server - Part 4 - Litespeed a web server

By Nick | April 2, 2007

First of all why did I choose Litespeed and not Apache or Lighttpd. Well, I first choose Apache + Mongrel to be my web server, but setting it up wasn’t that easy and once I got it running and did some testing on it. It turned out to be a very memory intensive combination. And that was at the time a only had one site and I was planning on expanding. So if only one site is using this many memory, howh much memory will two, three or more sites consume. I wanted to have three Mongrel instances per site, each consuming between 40 and 50 Mb. So I would quickly run out of memory and as they say memory is cheap, I started to look at other possibilities. I had heard of Litespeed a couple of months ago, but that was at the time their site was running on a Nuke version. And well Nuke isn’t known for its security, so I was turned away from it. But just at that time the new version 2.2 of Litespeed came out and there was a blog posting from Bob Silva on http://i.nfectio.us/articles/2006/09/04/litespeed-web-server-2-2-includes-rails-support with two videos demonstrating just how easy it is to setup Litespeed and configure a new Rails site. After seeing both videos I just had to test it. And as it turned out I liked it a lot more than Apache + Mongrel. Main advantages of Litespeed are: easy to administer (setting up a new Rails site is a breeze), very fast, scales very well (doesn’t use up so much memory as Apache + Mongrel did) and very easy to update.

Installation (note I’m using the latest 2.2.x version of Litespeed, you can already download the 3.0.x version, which has a better administration interface)

gem install ruby-lsapi
wget http://litespeedtech.com/packages/2.2/std/lsws-2.2.x-std-i386-linux.tar.gz
unzip Litespeed and ./install.sh
follow the steps from the installer

For security reasons I restricted the access to the admin console:

WebAdmin Configuration > Security > Access Control
Deny: ALL

With SSH you can tunnel to it and still have access to the admin console. For more information on getting a Rails site up and running look at the videos Bob Silva made, he did a wonderful job.

Some things you need to be aware of. Litespeed runs as the user nobody, so if you have caching turned on in your Rails project you have to make sure Litespeed is able to write to the tmp directory:

chown -R nobody:nobody rails-project-path/tmp (action caching)
chown -R nobody:nobody public/model-name (page caching)

You also need to change the rights of your production.log, otherwise Litespeed is unable to write to it:

chmod 666 /log/production.log

Oh, and another useful tip is, that when you encounter an error and something doesn’t work. Make sure you check lsws/logs/stderr.log, where the more obscure errors are reported.

So now you have setup your web server and you are able to start serving your pages to the world.

Topics: Rails, Litespeed |