How to Deploy a Test App on Dreamhost Rails 3.0.4

How to deploy a Test App on Dreamhost Rails 3.0.4?

I've been able to successfully get a Rails 3.2.2 app deployed to Dreamhost. Here are some notes I've written for myself.


On the local development machine

First off, Dreamhost Passenger is based on Ruby 1.8.7, not Ruby 1.9.2. Because of this, Dreamhost won't like some of your Ruby code because it has some of the new key value syntax. So look for any code like this:

key: "value"

and change it to Ruby 1.8.7 style (which Ruby 1.9.2 also can understand):

:key => "value"

I found that you can find this code by doing something like this...this can be done more efficiently on a *nix box, but this is how I did it in Windows with some *nix commands installed:

egrep -r -i "^.*\w: .*$" . | grep rb

After fixing the syntax, you'll want to bundle up your gems so Dreamhost doesn't complain about your rack version.

$> bundle package

On the Server (aka Dreamhost)

(Get your files on dreamhost. Personally, I commit and push changes into a git remote repository, then git pull them down to a private folder on dreamhost. After they are there, I copy them into the Passenger folder)

Then I run these commands from the Rails application folder (/home/username/www.myapp.com/):

$> bundle install --path vendor/bundle --local
$> rake db:migrate RAILS_ENV="production"
$> bundle exec rake assets:precompile
$> touch tmp/restart.txt

Voila, this seems to work. If it still isn't working, check the log/production.log.

Deploy a Rails app on Dreamhost

Based on your stack trace at http://www.foto-fiori.com/ it looks like there's a gem missing on your production server. Check the gem list in your environment.rb config file and ensure all gems are installed. You can also ssh into your application and run rake gems.

rake gems RAILS_ENV=production

You may want to freeze the gems if Dreamhost does not allow you to install them.

rake rails:freeze:gems

How do I set RAILS_ENV to 'Production' on a DreamHost shared server?

In a shared hosting environment, you will want to do this in a .htaccess file, placed inside public/. Mine looks like this:

PassengerEnabled on
PassengerAppRoot /home/myuser/myapp/current
RailsEnv production

Rails server dreamhost

The reason you are seeing this error is because bundler is not able to find the activesupport gem. Most likely you have installed Rails 3.2.8 locally and bundler is searching the system gem and failing to find it.

You should be able to resolve this with a bundle install --deployment.

I would make sure to set your environment variables first before running it and make sure they are correct.

gem env will show what they are currently set to.

export GEM_PATH=/usr/lib/ruby/gems/1.8
export GEM_HOME=~/.gems
export PATH=~/.gems/bin:/usr/lib/ruby/gems/1.8/bin:$PATH

bundle exec rails console should also help let you know whats failing.

I cannot use passenger for my ruby on rails application on dreamhost

Have you tried following the steps at http://railstips.org/2008/12/14/deploying-rails-on-dreamhost-with-passenger?

Rails 3.x startup error on Dreamhost - session_store.rb issue?

It looks like you're using Ruby less than 1.9 which doesn't support the new hash key syntax:
{ key: value }. Upgrade to Ruby 1.9+ and that should fix your issue.

Trivial Node.js via Passenger on DreamHost - Permission Denied

Unclear what solved the issue.

Ran through changing the permissions on the files, as would seem obvious. Changed '/home/<user name>/.nvm/versions/node/v12.16.3' to '/home/<user name>/.nvm/versions/node/v12.16.3/bin/node' in the .htaccess file. Neither of those seemed to solve it.

Repeated the process again later. Followed it by `touch <webapp directory>/tmp/restart.txt' and it started working. I had been editing files in the web app's directory, so it isn't clear what touching that file did.

Including ~/opt/lib libraries in a Passenger Rails App

The environment.rb way sounds like the way to go, though you might want to append to LD_LIBRARY_PATH instead. Also I'd make sure to use the full path to that directory just in case.

Alternatively you might be able to use .htaccess directives, similar to what is described @ http://wiki.rubyonrails.org/rails/pages/HowToUseOracleWithFastCGI



Related Topics



Leave a reply



Submit