During the substantial architectural operations going on for the Axelerant Dev Cloud (Projspace), I take a small break to write this blog wherein I will write about setting up a shared Rails hosting server.

Well, as discussed in the previous post we have a shared web hosting server where all the projects take their birth in the dev instance and then groomed properly in the test case and get mature in the production instance.

We have a host which serves LAMP and it has been doing an excellent job. As the time arrived to nurture our baby, Curamine we felt the need of a safe house for it and the thought striked the necessity of hosting Rails applications on a shared hosting server.

Tried employing several ways like fcgi, mongrel and finally got fixed to use passenger to host the rails apps. And thanks to rvm (http://rvm.io) Ruby Version Manager. We installed rvm globally which can be used by all the users. They can have their ruby, rails, gemset versions and host whatever. Multi-user installation is an awesome thing that can be done using rvm.

\curl -L https://get.rvm.io | sudo bash -s stable

This helps the user to have their ruby versions, rails versions and also gemsets. We are figuring out a way to take the gemset names from the developers to include them in the Apache vhost. Currently, the following is a sample vhost configuration.

<VirtualHost *:80>
LoadModule passenger_module /usr/local/rvm/gems/<gemset>/gems/passenger-4.0.0.rc4/libout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/<gemset>/gems/passenger-4.0.0.rc4
PassengerRuby /usr/local/rvm/wrappers/<gemset>/ruby
PassengerUser curamine
ServerName curamine.dev.axelerant.com
ErrorLog /home/curamine/logs/dev/error.log
DocumentRoot /home/curamine/www/dev/public
PassengerEnabled On
<Directory /home/curamine/www/dev/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
Options Indexes FollowSymLinks
Order allow,deny
allow from all

Note that curamine is the user account where the project is hosted. <gemset> should be somehow taken from the user and is to be filled in the vhost or think of a final option to give the developer an option of having .htaccess

This article was originally published February 19, 2013. It has been updated since then for clarity.