Ramaze with Passenger on Dreamhost

It’s easy to get Ramaze running on Dreamhost, as they are using Passenger. Here’s how:

Enabling Passenger

First log in to your Dreamhost control panel and go to you domain, you have to activate the option

Ruby on Rails Passenger (mod_rails)?

Then the setting for

Specify your web directory:

should point to the public folder in the directory where your ramaze application will live

Install gems in you home directory

Dreamhost does not provide the Ramaze gem, the easiest thing to do is to install your required gems in your home directory

First create a directory to hold the gems

mkdir ~/.gems

Then update your environment

~/.bash_profile

export GEM_HOME=$HOME/.gems
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8

Then logout/login or execute this line to have your environment updated

source ~/.bash_profile

Now you can install your own gems

gem install ramaze --no-rdoc --no-ri

I’m using the flags to avoid generating the documentation, this is fairly process intensive and Dreamhost will probably kill you process. You should have your own development environment on your computer anyway if you need the doc

Creating a Ramaze app

I will not cover the creation of a Ramaze application, there is a lot of good tutorial already

Hosting your Ramaze app on Dreamhost

In the root of your application directory you need a rackup file for Passenger. ‘start’ being the bootstrap file for your application, this is needed as we need to update GEMPATH to our own gems, this cannot be done in the config.ru file for some obscure reason

config.ru

require 'start'

Ramaze.trait[:essentials].delete Ramaze::Adapter
Ramaze.start :force => true
run Ramaze::Adapter::Base

Now the important part, the start.rb file need to have information on your gems folder, right after the inclusion of rubygems

start.rb

require 'rubygems'
#needed to avoid the Passenger exception page every hour or so
Gem.clear_paths
#use my own gem when availlable
Gem.path.unshift('/path/to/my/home/.gems')

require 'ramaze'

# require all controllers and models
acquire __DIR__/:controller/'*'
acquire __DIR__/:model/'*'

That’s all folk! By the way, it should work with Merb too.

Posted Tuesday, September 23rd, 2008 under ruby.

Comments are closed.