How to deploy a Test App on Dreamhost Rails 3.0.4?

我只是一个虾纸丫 提交于 2019-12-21 05:28:27

问题


All this weekend I have been trying to setup a Rails 3.0.4 app in production on a Dreamhost shared server. I have followed this wiki article to have my own set of rubygems setup on the server. Furthermore, I also installed rvm and ruby 1.9.2 using the following command:

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
rvm use 1.9.2 --default

Doing ruby -v returns ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux], so I believe rvm has installed the version of ruby correctly.

I created my app forcing the use of a mysql database, and then generated an articles controller:

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

Now when I visit the domain I see the usual "Welcome aboard You’re riding Ruby on Rails!" screen, but if I click the "About your application’s environment" link I get what looks like to be some kind of passenger error:

Ruby (Rack) application could not be started The application has exited during startup (i.e. during the evaluation of config/environment.rb). The error message may have been written to the web server's log file. Please check the web server's log file (i.e. not the (Rails) application's log file) to find out why the application exited. If that doesn't help, then please use the backtrace below to debug the problem.

Lastly, if I SSH into the server and just do rails s I can see the app functioning correctly on port 3000.

I have never put an app into production before, so I am very confused. Is passenger not using the RVM version of ruby? Is these even possible on a DreamHost shared server? What do I have to do to rectify this problem?

Any help is appreciated, Thanks.


回答1:


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.




回答2:


I've bumped into the same problem. I believe it's because passenger is not loading the ruby interpretor you specify in rvm as it or gems you specify. You'll likely see that the gems being loaded refer to /usr/... I did bump into this http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration, but I haven't been able to get around that Dreamhost is using ruby 1.8.7 in it's passenger configuration and you and I would like to use 1.9.2



来源:https://stackoverflow.com/questions/5072197/how-to-deploy-a-test-app-on-dreamhost-rails-3-0-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!