Dreamhost + Rails3 + Passenger = STRESS

apps

#1

I have been trying unsuccessfully for what seems like two weeks to deploy a simple Rails3 app to my Dreamhost shared server using Passenger.

I will admit that I am very new to Rails 3 and Passenger, but I feel like I have a pretty good grip on Unix / shell / development in general so I can handle some technical input.

This is where I stand:

I have created a very simple mysql rails 3 app:

rails new test_app -d mysql cd test_app rails g scaffold articles title:string body:text

Next, I modified config/database.yml to something like this:

[code]# MySQL. Versions 4.1 and 5.0 are recommended.

Install the MySQL driver:

gem install mysql2

And be sure to use new-style password hashing:

http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:
adapter: mysql2
encoding: utf8
reconnect: false
host: hostname
database: db_dev
pool: 5
username: user
password: pass
socket: /tmp/mysql.sock

Warning: The database defined as “test” will be erased and

re-generated from your development database when you run “rake”.

Do not set this db to the same as development or production.

test:
adapter: mysql2
encoding: utf8
reconnect: false
host: hostname
database: db_test
pool: 5
username: user
password: pass
socket: /tmp/mysql.sock

production:
adapter: mysql2
encoding: utf8
reconnect: false
host: hostname
database: db_prod
pool: 5
username: user
password: pass
socket: /tmp/mysql.sock[/code]

I loaded the app into a Passenger-enabled subdomain and ran:

(I realize DH’s wiki claims that this process will be killed, but for whatever reason it isn’t and all gems are installed into my ~/.gems/ directory successfully)

At this Passenger appears to run fine and I can see the standard “Welcome aboard” index. The problem is if I attempt to browse to my “/articles” page I receive a 500 (Internal Service Error).

The interesting thing is if I run the app via “rails s” I can view the site on port 3000 and everything works fine. I can add, remove, edit articles etc. I can even run the app with “rails s -e production” and it runs fine in production mode on port 3000 (naturally the index and stylesheets don’t load by default because “config.serve_static_assets = false”).

From the research that I’ve done, it has been suggested that any 500 errors are a result of an Apache configuration and that if there’s a problem with passenger you’ll receive a passenger error page that is “prettier” (i’ve seen these, so I sort of understand what that means). I also thought that it could be a permissions issue as I’ve seen 500 errors result from apache not being able to access certain assets so I dropped the 777 bomb on my app’s directory (recursively) and that didn’t do anything for me.

I also played around with the ENV[‘GEM_PATH’] and ENV[‘GEM_HOME’] variables in my config/environments/production.rb file (i’m not even sure that’s where something like that would belong, but its the best place I could come up with having not seen rails 3 suggestions anywhere…) and had no luck there.

Has anyone successfully run a Rails 3 app on Dreamhost with Passenger since their upgrade? I feels like there are still some missing pieces from the upgrade (perhaps on purpose), but gems like “builder” and an up to date “tzinfo” are not installed and therefore you can’t even create a new rails 3 app on the default state of a shell user…

HELP!


#2

It never fails. You teeter on the edge of self mutilation over a problem. You finally throw in the towel and post for help online. You solve the problem yourself.

As I suspected, Passenger was having a genuinely difficult time locating my user-installed gems. The problem was, I didn’t know how to tell Passenger / Rails “Hey! They’re right here!”. I started playing with Sinatra today and ran into some of the same issues. Lucky for me, sinatra is a MUCH lighter application so I easily tracked down the problem to not locating the gems. The best part was, pretty much everything happens in config.ru. So I started search around. And there they were…

ENV['GEM_HOME'] = '/home/USERNAME/.gems' require 'rubygems' Gem.clear_paths

You set GEM_HOME (see: http://docs.rubygems.org/read/chapter/12#page52 for what all the environment variables actually are!) and then tell the Gem module to clear its paths which resets the the gem path values from scratch based on the environment variables (http://rubygems.rubyforge.org/rubygems-update/Gem.html#method-c-clear_paths).

Once your app can find its gems, we’re back to smooth riding :wink:


#3

Thank you very much!
I almost gave up to make my Rails project running at Dreamhost!


#4

I got my Rails 3 Opal app working this way. Thanks!

By the way, on DH, it’s important not to specify ENV[‘GEM_PATH’] in config.ru, this may break your app(as it did mine). Just override ENV[‘GEM_HOME’] and you’ll be golden.