Displaying articles with tag dreamhost

Merb on Dreamhost

Posted by PunNeng, Sat Aug 02 20:18:00 UTC 2008

Get started

Make sure that Ruby on Rails Passenger (mod_rails) is enabled on your domain.
To do that, go to the Domains > Manage Domains section of your panel and then click the "Edit" link next to your domain. On the next page make sure "Ruby on Rails Passenger (mod_rails)?" is enabled. Also, specify your web directory and then click the "Save Changes" button.

Create a directory for compiled packages and Gems

I recommend Ruby 1.8.6 at for running Merb and it is Ruby 1.8.5 on Dreamhost currently. Fortunately, Dreamhost allows installing the own gems and pacakges and nateclark has already blogged which is really good way to follow.

Actually, I needed Readline also but I couldn't get it work. Can anyone get it work?

Install Merb

4 ninjas has already written how to. Install Merb locally and there will be a few problems when you install domysql(dopostgres and do_sqlite3) if you prefer DataMapper. On Ubuntu, it can't find lmysqlclient or can't find mysql.h
To fix that problems,

$ sudo apt-get install mysql
$ sudo apt-get install libmysqlclient15-dev

On OSX, there will be a problem also. The problem is it can't find mysql home. To fix that, open Rakefile in do/do_mysql/ and change these codes below

  1
  2
  3
task :install => [ :package ] do
  sh %{#{SUDO} gem install --local pkg/#{spec.name}-#{spec.version} --no-update-sources}, :verbose => false
end

to

  1
  2
  3
task :install => [ :package ] do
  sh %{#{SUDO} gem install --local pkg/#{spec.name}-#{spec.version} --no-update-sources -- --with-mysql-dir=/usr/local/mysql}, :verbose => false
end

add

-- --with-mysql-dir=/usr/local/mysql

After you install all gems on your machine, you will have a lot of gems. Just upload all gems to your home on DH and install them.

I have had problems with Dreamhost's shared gems conflicting with gems that you install locally. To fix that, open ~/.bashrc and change $GEM_PATH to

export GEM_PATH="$GEM_HOME"

Merb app configuration

create config.ru to your home app

  • app
    • ...
    • public
    • config.ru << add it

and put these codes below to config.ru

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
# config.ru

ENV['GEM_PATH'] = '/home/your_home/.gems/' # your local gem home

require 'rubygems'
# There were a few problems on loading merb-core at the firt time after Passenger pid has been killed. These codes below were added to fix.
["/home/your_name/.gems/gems/abstract-1.0.0/bin", 
"/home/your_name/.gems/gems/abstract-1.0.0/lib", 
"/home/your_name/.gems/gems/erubis-2.6.2/bin", 
"/home/your_name/.gems/gems/erubis-2.6.2/lib", 
"/home/your_name/.gems/gems/json_pure-1.1.3/bin", 
"/home/your_name/.gems/gems/json_pure-1.1.3/lib", 
"/home/your_name/.gems/gems/rspec-1.1.4/bin", 
"/home/your_name/.gems/gems/rspec-1.1.4/lib", 
"/home/your_name/.gems/gems/mime-types-1.15/bin", 
"/home/your_name/.gems/gems/mime-types-1.15/lib", 
"/home/your_name/.gems/gems/merb-core-0.9.4/bin", 
"/home/your_name/.gems/gems/merb-core-0.9.4/lib"].each do |path|
  $LOAD_PATH << path
end
require 'merb-core'

Merb::Config.setup(:merb_root   => ".",
                   :environment => ENV['RACK_ENV'])
Merb.environment = Merb::Config[:environment]
Merb.root = Merb::Config[:merb_root]
Merb::BootLoader.run

run Merb::Rack::Application.new

and

$ touch tmp/restart.txt

for restarting

Example

Thanks again:
nateclark
4 ninjas
Merb's wiki

4 comments | Filed Under: Merb | Tags: dreamhost

codegent: we're hiring