Litespeed - Serve a Rails domain
The Ruby on Rails host template has been configured and, now that we've installed Mephisto, we have a full Ruby on Rails Application for Litespeed to serve.
After the basic setup, adding new Ruby on Rails domains takes seconds.
In you have installed PHP and followed the Serve a PHP domain article, you may find many of the items below are repeated from that article.
This is intentional as many will not have followed the PHP articles and will not have set the relevant permissions:
When we first created the user 'paul', it was in the group 'paul'. When we setup Litespeed we used the user www-data in the group www-data.
You may notice the difference in the names! First thing is to add the user 'paul' to the group www-data:
sudo usermod -a -G www-data paul
This simply adds the user 'paul' to the group 'www-data'. You will have to log out and log back in for the group change to take effect. You can see what groups your username belongs to via:
groups
If it reports more than paul and www-data ask yourself if 'paul' needs to be in those groups.
Referring to our Mephisto Install or looking back to the Virtual Host Layout article, we see the Ruby on Rails domain lives in our public_html folder. Move into that folder now:
cd ~/public_html
Once the Rails Application has been created it is incredibly simple to serve.
Firstly, change the group of the public_html directory:
sudo chgrp -R www-data ~/public_html
When a file is written by Litespeed, for example when uploading a file or creating a dynamic page, the file is given the user and group www-data as that is the user and group the Litespeed server belongs to.
We need to make sure that each file and folder is readable and writeable by the user paul and the group www-data. To enable this, we use the command:
sudo chmod -R 2770 ~/public_html
The 2 makes the permissions 'sticky' so any file written by the user is given the group www-data. The 770 means that the user and the group have read/write permissions and everybody else has nothing - they can't even see the files.
That's the setup done (told you it was easy).
Next, login to the Litespeed Admin Area and go to the Virtual Host Template area:
Click on the EasyRailsWithSuEXEC link:
Click on 'Add' in the Member Virtual Hosts area. You will see a very simple form - we have to fill out three boxes - 'Virtual Host Name', 'Domain' and 'Aliases':
When we installed Mephisto, it was installed into the railsdomain.com directory. Simply replace this name with whatever your Rails Application directory is called. For consistency and ease of administration, call the Virtual Host Name the same as your domain name:
Virtual Host Name railsdomain.com
Domain railsdomain.com
Aliases www.railsdomain.com
That's all the configuration you have to do. Three bits of information. No load balancers, no mongrels, no messing.
Click 'Save'. You will notice that your new domain has been added to the Member Virtual Hosts list:
You could leave the domain there but we are going to 'Instantiate' it. This simply means that it will be an independent Virtual Host so if any changes were made to the EasyRails template, it would have no effect on our domain. It also means we can tweak and adjust any setting within our Rails Domain and it will not effect anything else.
So, click 'Instantiate', confirm you want to do this by clicking 'Yes' (very Windows like!), Apply Changes and gracefully restart the server.
Now, assuming you have the domain DNS pointing to your VPS (if not, see the setting up your domain article), navigate to your domain, i.e. http://www.railsdomain.com, where you will be greeted with the Mephisto Welcome Page.
Serving a Ruby on Rails Application has never been easier! Seriously, is there a more efficient way of serving Rails domains? To add more domains, simply repeat the process.
PickledOnion.
P.S. If you have setup Mephisto, don't forget to login to the admin area as soon as possible and change the default username and password (admin/test).
Digg it |
del.icio.us |
reddit |
StumbleUpon

Subscribe to Feed
Article Comments:
Richard 30 May, 2007
This has been a great series of articles - thanks very much.
As a someone new to VPS and to slicehost, this has been very educational and effective in getting me up and running.
Thanks again.
PickledOnion 30 May, 2007
Richard,
Thanks for your kind comments. I hope you enjoy your VPS and don't hesitate to get in touch if I can help.
PickledOnion
Richard 30 May, 2007
Me again...I managed to instantiate my virtual host based on the Rails template, and that went fine.
I notice that I now have an 'empty' listener but with no settings. Is this to be expected or do I need to edit the listener?
PickledOnion 31 May, 2007
Richard,
There should be at least the instantiated vhost in the Listener box. Although you can add the domain by hand, it should have been created along with the instantiated vhost.
Could you email me so we could work this out?
Many thanks,
PickledOnion.
Dan 10 Sep, 2007
thanks very much mate.. i'm brand new to VPS, Linux, and just about everything else discussed in these articles, and with your help i'm now up and running..
cheers,
dan
Joe 08 Oct, 2007
Hey man, these walk-throughs are clutch! Awesome, awesome work... I a unclear about how to put a rails app into "production" mode using litespeed. Has this been covered anywhere?
PickledOnion 08 Oct, 2007
Joe,
In the vhosts section for the domain, select the Context Tab and then click the 'edit' link next to the Rails context.
Then simply select the mode from the Rails Environment drop down box.
Then restart Litespeed.
Simple as that :)
PickledOnion