如何在 Dreamhost Rails 3.0.4 上部署测试应用程序? [英] How to deploy a Test App on Dreamhost Rails 3.0.4?

查看:56
本文介绍了如何在 Dreamhost Rails 3.0.4 上部署测试应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

整个周末,我一直在尝试在 Dreamhost 共享服务器上的生产环境中设置 Rails 3.0.4 应用程序.我已经按照 这篇 wiki 文章 在服务器上设置了我自己的一组 ruby​​gems.此外,我还使用以下命令安装了 rvm 和 ruby​​ 1.9.2:

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

执行ruby -v 返回ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux],所以我相信rvm已经安装了红宝石正确.

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.

我创建了强制使用 mysql 数据库的应用程序,然后生成了一个文章控制器:

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

现在,当我访问该域时,我会看到通常的欢迎加入您正在使用 Ruby on Rails!"屏幕,但如果我点击关于您的应用程序的环境"链接,我会看到某种乘客错误:

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) 应用程序无法启动应用程序在启动期间退出(即在 config/environment.rb 评估期间).错误消息可能已写入 Web 服务器的日志文件.请检查 Web 服务器的日志文件(即不是(Rails)应用程序的日志文件)以找出应用程序退出的原因.如果这没有帮助,那么请使用下面的回溯来调试问题.

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.

最后,如果我通过 SSH 连接到服务器并执行 rails s,我可以看到应用程序在端口 3000 上正常运行.

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

我以前从未将应用程序投入生产,所以我很困惑.乘客不使用 RVM 版本的 ruby​​ 吗?在 DreamHost 共享服务器上这些甚至可能吗?我该怎么做才能解决这个问题?

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?

感谢任何帮助,谢谢.

推荐答案

我已经能够成功地将 Rails 3.2.2 应用程序部署到 Dreamhost.以下是我为自己写的一些笔记.

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.

首先,Dreamhost Passenger 基于 Ruby 1.8.7,而不是 Ruby 1.9.2.因此,Dreamhost 不会喜欢您的某些 Ruby 代码,因为它具有一些新的键值语法.所以寻找任何这样的代码:

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"

改变为Ruby 1.8.7风格(Ruby 1.9.2也能理解):

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

:key => "value"

我发现你可以通过做这样的事情来找到这段代码......这可以在 *nix 机器上更有效地完成,但这是我在安装了一些 *nix 命令的 Windows 中做到的:

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

修复语法后,您需要打包您的 gem,这样 Dreamhost 就不会抱怨您的机架版本.

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

$> bundle package

<小时>

在服务器上(又名 Dreamhost)

(在 Dreamhost 上获取您的文件.就我个人而言,我将更改提交并推送到 git 远程存储库中,然后 git pull 将它们下放到 Dreamhost 上的一个私人文件夹中.在它们到达之后我将它们复制到Passenger文件夹中)


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)

然后我从 Rails 应用程序文件夹 (/home/username/www.myapp.com/) 运行这些命令:

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

瞧,这似乎有效.如果它仍然不起作用,请检查 log/production.log.

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

这篇关于如何在 Dreamhost Rails 3.0.4 上部署测试应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆