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.)