Harrington Web

Setup Sinatra Application on Hostmonster.

Monday, January 27, 2014

Step 1 - Environment Setup

Make sure that you have ruby installed on environment, and have SSH access. To your account.

Step 2 - Create Ruby on Rails Environment

  1. Login to your Hostmonster C-Panel.
  2. Click Ruby on Rails icon.
  3. Fill out form with your information

Step 3 - Setup Directory Link

SSH into your account and goto where you would like the base of your app to be in. For example if you have website www.example.com and you want it hosted at www.example.com/myApp

ln -s ~/rails_apps/myApp ~/public_html/myApp

Step 4 - Clean up automatic Rails files.

rm -Rf ~/rails_apps/myApp/*

Once you have cleaned up the directory copy your sinatra files to ~/rails_apps/myApp

If you have a Gemfile this would also be a good time to run a "bundle install" while you are in the directory. If you don't get your gems loaded you will experience problems.

Step 5 - Setup your .htaccess file

Open up your .htaccess file for the myApp directory and make it look like this. Make sure that you replace the sections that say "yourAccount" and "myApp" with the appropriate names for your domain and application.

<IfModule mod_passenger.c>
  Options -MultiViews
  Allow from all
  PassengerResolveSymlinksInDocumentRoot on
  #Set this to whatever environment you'll be running in
  RailsEnv production
  RackBaseURI /
  PassengerAppRoot /home1/yourAccount/rails_apps/myApp
  SetEnv GEM_HOME /home1/yourAccount/ruby/gems
</IfModule>

Step 6 - Restart your app

touch ~/rails_apps/myApp/tmp/restart.txt
Remember this little trick to restart the app. This allows you to restart the Sinatra application without having to restart apache.

No comments :

Post a Comment