Litespeed - Rails Vhost configuration
Let's customise the EasyRailsWithSuEXEC template to fit our virtual host directory layout. Once done, adding Ruby on Rails virtual hosts to our Litespeed Server takes no time.
Log into the Administration area and then hover over 'Configurations' and click 'Virtual Host Templates':
You'll be presented with the Virtual Host Templates page which has three pre-defined templates for us: EasyRailsWithSuExec, PHP_SuExec and centralConfigLog:
Click on the EasyRailsWithSuEXEC. You're probably getting used to the layout of Admin Area by now as the layout is very similar to the PHP_SuEXEC layout. The majority of the layouts follow the same pattern - allowing for quick and easy administration.
The first tab gives details of the template itself (note that you can change the location of the configuration xml file). Once setup to your liking, it's a good idea to copy the templates/rails.xml file for quick transfer to another server.
The General Tab will need Template Settings, Virtual Host Log and Access Log values changing. Click on the 'edit' link for the Template Settings values and change them to those shown below:
Virtual Host Root /home/paul/public_html/$VH_NAME/
Config File $VH_ROOT/config/$VH_NAME.xml
Max Keep-Alive Requests 1000
Smart Keep-Alive yes
Document Root $VH_ROOT/public/
All we are changing are the default locations for some items. Referring to the Virtual Host Layout article will give a reminder as to the directory layout used for these articles - all the domains are in our home folder's public_html directory.
Click 'save' and move on to edit the Virtual Host Log setting. As we like complete control over our virtual hosts, we put the log files in a folder within our virtual host's directory:
Use Server's Log no
File Name $VH_ROOT/log/error.log
Log Level ERROR
Rolling Size (bytes) 10M
Save the changes and move down to the Access Log box. Edit the File Name value:
File Name $VH_ROOT/log/access.log
If you've been following the PHP Virtual Host article you will see they are almost identical at this stage. There's a good reason for this in that I attempt to mirror as many settings and layouts as possible between my PHP sites and my Ruby on Rails sites. This consistency allows for easier administration over different sites and different servers.
The Security, External App and Rewrite Tabs can be left at the default values at this stage but the Context Tab has something of interest:
Click on the 'edit' link. There is only one value to change here and that is 'Max Connections':
Max Connections 10
If you remember when the Server Ruby on Rails settings were changed (see the Litespeed Configuration article), the Max Connections were changed to 10. Keep the same value here, although individual virtual host settings can be made.
I'm going to repeat the advice I gave in the Litespeed Configuration article: It should be noted that on a smaller VPS, say 128MB, the Max Connections should be set at 2, or 3 at the most (although 128MB is too small to run a Rails App effectively anyway). One of the biggest problems with slow Ruby on Rails Apps is setting this value too high.
Click 'save', apply the changes and gracefully restart the server.
For those used to configuring load balancers and mongrel clusters and so on, it may seem that more needs to be done to get our Rails App up and running. The nice surprise is that there is no other configuration to do. The Ruby on Rails Application will be served by Litespeed's LSAPI and all we had to do was define the number of connections.
That's it for the Ruby on Rails Virtual Host Configuration. The next article will create a virtual domain and start to serve it to the public (now the settings are complete this takes less than 10 seconds per domain - you will really start to appreciate the power of this setup.)
PickledOnion.
Digg it |
del.icio.us |
reddit |
StumbleUpon

Subscribe to Feed
Article Comments:
dirtymafia 06 May, 2007
Just wanted you to know that you are #10 on a google search for "litespeed with ruby on rails" w/o quotes even.
PickledOnion 06 May, 2007
Hey, thanks dirtymafia. Not bad for less than a month live in the wide wild web :)
I'll try and keep it going.
Marston A. 08 May, 2007
Good writeup, thanks for putting it up.
We're also using LiteSpeed for our project and love it.
I'd love to see a writeup for tuning a default LiteSpeed install and modifying the config variables for speed (Say on 512MB/1GB VPS's or dedicated servers) if you have time one of these days.
PickledOnion 10 May, 2007
Many thanks for the comment.
A tuning and performance under load section is definitely something I have planned for the future. I want to ensure it is a fair as possible and under as many different (simulated) environments as possible so it may take a while!
Ajay 16 May, 2007
Thanks for the nice article. With in couple of hour I could get my site up. Was very informative and excellent work.
Please don't stop this series and keep up the best work.
If time permits can you also write a article on Subversion and Capistrano.
Thanks, Ajay
PickledOnion 16 May, 2007
Ajay, I'm glad they could help.
Be assured I won't stop writing the articles - I have a lovely long list to work my way through!
The list does include subversion, svnserve and bsSvnBrowser. I'm afraid Capistrano is pretty low on the list but it is there.
Richard 31 May, 2007
Shouldn't the document root for the Rails domain be VHROOT/public/ and not VHROOT/public_html/ ?
ericsessions 31 May, 2007
Thanks for all your work creating these articles! I am having a frustrating problem with my slice. When I try to instantiate my virtual host and reboot the server, I get these two error messages
2007-05-31 03:07:20.770 ERROR [config:vhost:ericsessions.com] Path for document root is not accessible: /home/eric/publichtml/ericsessions.com/publichtml/
2007-05-31 03:07:20.770 ERROR [config:vhost:ericsessions.com] configuration failed!
I didn't know what else to do so I did chmod 777 config and it wrote the file but I can't make it instantiate. By the way I have been following your articles to get my slice set up. Thanks!
PickledOnion 31 May, 2007
Richard,
You are absolutely correct. Thanks so much for pointing that out. I have changed it to the correct entry: VHROOT/public/
Many thanks,
PickledOnion
PickledOnion 31 May, 2007
ericsessions,
If you note the comment from Richard any my reply, you will see that I made a booboo!
The Document Root should point to VHROOT/public/ and not VHROOT/public_html/.
Apologies for any confusion.
Pickledonion.