Sep 24 2009

Installing Sinatra on Site5

Category: ruby,tutorialgiordano scalzo @ 11:28 am

I think Rails is a wonderful framework that boosts the success of Ruby, but sometimes is a a little overkill.
Enter Sinatra, a microframework in Ruby, aims to create simple web applications.

As mentioned in a previous post, I own a shared access on a Site5, so I began to search any documentation to install a simple Sinatra app on Site5.
I didn’t find a lot of documentation, but a post gave some hints in the right direction.

First of all, it need to install locally Sinatra gem configuring GEM_PATH and GEM_HOME.
Then we need to create a subdomain, i.e., where we’ll implement Sinatra’s app. For an unknown reason, I’d to configure a subdirectory as document root:

Domain Configuration

The htaccess directory contains the file .htaccess that enables Phusion Passenger:

PassengerEnabled on
RackBaseURI /

In parent directory we write the Phusion Passenger configuration,

ENV['GEM_PATH'] = "/home/USER/gems:/usr/lib/ruby/gems/1.8"
ENV['GEM_HOME'] = "/home/USER/gems"
require 'rubygems'
require 'sinatra'

require 'app'
run Sinatra.application

and our Sinatra application (I call it app):

get '/' do
  "Hello World!"
get '/hi' do
  "Hi World!"

That’s it!
Now we can call the urls ‘‘ and ‘‘.

Technorati Tags: , ,

Tags: , ,

  • John

    I thought I would show what I had to do (with the help of site5 great staff) to get your tutorial to work on the current site5 ruby setup.
    Add the following line below your 2 ENV lines in the file:

    Without it, ruby cant’t seem to find the sinatra gem installed.

  • rengo.Java

    I cant get clearly where to put the .htaccess and files.
    How is the directory tree?
    /home/your_user/sinatra/htaccess ?

  • Nathan Fritz

    John is correct. Something changed, and now rubygems are loading too early to honor the environmental variables.

    I corrected it with:

    require ‘rubygems’ || Gem.clear_paths

    I did a write up (and cited your post) at: