Thursday, January 17, 2008

Installing Mongrel on a Linux box

So I wanted to run Mongrel on a linux box in which I did not have root authority.

My configuration
  1. ruby 1.8.5 (2006-08-25) [i386-linux]
  2. gem version 0.9.4
Simply run:
gem install mongrel -i [dir_you_can write_to] (You may have to run this twice if the first invocation gives an error)

You will see something like:
Select which gem to install for your platform (i386-linux)
1. mongrel 1.1.3 (java)
2. mongrel 1.1.3 (i386-mswin32)
3. mongrel 1.1.3 (ruby)
4. mongrel 1.1.2 (ruby)
5. mongrel 1.1.2 (mswin32)
6. mongrel 1.1.2 (java)
7. Skip this gem
8. Cancel installation

I picked 3. Hopefully this works with out a problem.

You will also need:
gem install rails -i [dir_you_can write_to]

In the
[dir_you_can write_to], you will find bin/mongrel_rails.
Go to your directory containing the rails application and run

[dir_you_can write_to]/bin/mongrel_rails.
After invoking this, I received the following error message:
/usr/lib/ruby/site_ruby/1.8/rubygems.rb:303:in `report_activate_error': Could not find RubyGem mongrel (> 0) (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:237:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:75:in `active_gem_with_options'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:49:in `gem'

The solution for this is to set GEM_PATH like so:
export GEM_PATH=/non_default_gems_install/ruby_gems

Try running this again

[dir_you_can write_to]/bin/mongrel_rails start -p 8000

Open a browser pointing it to server:8000 should display the rails application.

1 comment:

thebitguru said...

This helped solve my deployment issue! Thanks a lot for sharing.