Ruby on Rails Web Hosting with Lunarpages

Running Multiple Ruby on Rails Applications on One Domain

Ruby on Rails is the hot new framework for the Ruby language that supports Ajax , database migrations and other cool features. Using Rails, however, it might not appear straightforward how you can have multiple applications on one domain. This tutorial will cover how you can achieve this goal in only a few steps.

The Main Application

Let's say you have setup a folder called rails1 where your main Rails application is housed. You've placed this folder outside your publicly accessible folder level at /home/username/ (so the full path would be /home/username/rails1). Please note the example path could be different, but it would be whatever is your domain's root level, which is one level above and outside your publicly viewable folder. In this example, the folder where web applications are viewable would be the /home/username/public_html path.

Next, you want to have your Rails application public folder (/home/username/rails1/public) symlinked to your web folder ( /home/username/public_html), so you would issue the following set of commands in most Linux environments:

cd /home/username
mv public_html public_html.old
ln -s /home/username/rails1/public /home/username/public_html
chown username:nobody /home/username/rails1/public

The final chown would need to match the ownership your web folder (public_html in our example) normally would have. Please check the ownership by listing ( ls -l /home/username) and seeing what public_html shows for ownership and file permissions before you move the folder to public_html.old and you should then chown or chmod the /home/username/rails1/public folder to those same values.

The Next Application

Let's say your next application is called rails2 and resides at the /home/username/rails2 path. You want to have it publicly viewable as a folder on your domain, so you use the following commands to symlink it:

ln -s /home/username/rails2/public /home/username/public_html/rails2

In this example, please note that the rails2 folder should not already exist inside public_html for the symlink. Additionally, please note that you can call the folder inside public_html anything: It does not have to have the same name as the Rails application at /home/username/rails2 does.

After doing this symlink, you would need to make one change to your Rails application in order for it to work. Go to /home/username/rails2/public and open the .htaccess file . Uncomment or add this line:

# RewriteBase /myrailsapp

to

RewriteBase /myrailsapp

Then change the line to match your folder's name:

RewriteBase /rails2

Now, you have 2 Rails applications running on your domain. You would even be able to add more Rails applications using this same method.

Have fun riding the Rails!

5 Things You Can Do With Ruby on Rails

The Advantages of Ruby on Rails Web Hosting

The Disadvantages of Ruby on Rails Web Hosting

Ruby on Rails Web Hosting Services

Tested for safety by the Safe Shopping Network Host Critique Award WebHost Magazine Award Hosting Review Award Top 8 Web Hosting Award Listed on Dunn & Bradstreet