Skip to content

Instantly share code, notes, and snippets.

@overdawn
Created March 8, 2014 12:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save overdawn/9429871 to your computer and use it in GitHub Desktop.
Save overdawn/9429871 to your computer and use it in GitHub Desktop.
Deploy Sinatra application on shared hosting using Passenger (hostmonster)

Deploy Sinatra application on shared hosting using Passenger (hostmonster)

Prepare the application

  • Create folder ~/yourapp
  • Create folder ~/yourapp/tmp
  • Create file ~/yourapp/config.ru with the following content:
# encoding: UTF-8
require './appmain'
run Sinatra::Application
  • Create file appmain.rb with the following content:
# appmain.rb
require 'sinatra'

get '/' do
  'Hello world!'
end

Install gems

I installed gems sinatra and rubygems (maybe the latter is not needed). This can be done either using Terminal (gem install sinatra) or using cPanel.

Configure the web root

In the ~/public_html folder create/modify .htaccess with the following content:

SetEnv GEM_HOME /home/.../ruby/gems
PassengerAppRoot /home/.../yourapp

where /home/.../ruby/gems is the path to your local folder where the gems got installed and /home/.../yourapp is a full path to ~/yourapp.

Restart the Passenger

Sometimes after updating config.ru Passenger has to be restarted (otherwise the application does not get updated). To do this simply go to ~/yourapp and

touch tmp/restart.txt

I've created a file restart.sh with the content

#!/bin/sh

touch tmp/restart.txt

and run chmod a+x restart.sh so that I can simply execute ./restart.sh to restart Passenger.

@dfockler
Copy link

You rock! This really helped me. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment