【发布时间】:2013-08-06 10:17:07
【问题描述】:
我第一次尝试不是将 Rails 应用程序部署到 Heroku,而是部署到 DigitalOcean,主要是因为价格。我对 Capistrano 以及 VPS 部署完全陌生,我完全迷失了。我创建了 1-click-Rails-droplet 并按照本教程进行操作: http://guides.beanstalkapp.com/deployments/deploy-with-capistrano.html
这是我的 deploy.rb 文件中的设置:
require 'capistrano/ext/multistage'
set :stages, ["staging", "production"]
set :default_stage, "staging"
set :application, "myAppName"
set :scm, :git
set :repository, "myGitRepository"
set :use_sudo, :false
set :deploy_via, :remote_cache
set :scm_passphrase, "myPassword"
set :user, "root"
role :web, "xx.xxx.x.xxx"
role :app, "xx.xxx.x.xxx"
staging.rb 文件:
server "xx.xxx.x.xxx", :app, :web, :db, :primary => true
set :deploy_to, "/var/www/xx.xxx.x.xxx_staging"
还有production.rb文件
server "xx.xxx.x.xxx", :app, :web, :db, :primary => true
set :deploy_to, "/var/www/xx.xxx.x.xxx"
现在,当我跑步时
cap deploy:check
在终端中我得到以下信息:
[xx.xxx.x.xxx] executing command
xx.xxx.x.xxx: env:
xx.xxx.x.xxx: sh
xx.xxx.x.xxx: : No such file or directory
xx.xxx.x.xxx:
command finished in 88ms
* executing "test -w /var/www/xx.xxx.x.xxx_staging"
servers: ["xx.xxx.x.xxx"]
[xx.xxx.x.xxx] executing command
xx.xxx.x.xxx: env:
xx.xxx.x.xxx: sh
xx.xxx.x.xxx: : No such file or directory
xx.xxx.x.xxx:
command finished in 79ms
* executing "test -w /var/www/xx.xxx.x.xxx_staging/releases"
servers: ["xx.xxx.x.xxx"]
[xx.xxx.x.xxx] executing command
xx.xxx.x.xxx: env:
xx.xxx.x.xxx: sh
xx.xxx.x.xxx: : No such file or directory
xx.xxx.x.xxx:
command finished in 72ms
* executing "which git"
servers: ["xx.xxx.x.xxx"]
[xx.xxx.x.xxx] executing command
xx.xxx.x.xxx: env:
xx.xxx.x.xxx: sh
xx.xxx.x.xxx: : No such file or directory
xx.xxx.x.xxx:
command finished in 85ms
* executing "test -w /var/www/xx.xxx.x.xxx_staging/shared"
servers: ["xx.xxx.x.xxx"]
[xx.xxx.x.xxx] executing command
xx.xxx.x.xxx: env:
xx.xxx.x.xxx: sh
xx.xxx.x.xxx: : No such file or directory
xx.xxx.x.xxx:
command finished in 81ms
The following dependencies failed. Please check them and try again:
--> `/var/www/xx.xxx.x.xxx_staging/releases' does not exist. Please run `cap staging deploy:setup'. (xx.xxx.x.xxx)
--> You do not have permissions to write to `/var/www/xx.xxx.x.xxx_staging'. (xx.xxx.x.xxx)
--> You do not have permissions to write to `/var/www/3xx.xxx.x.xxx_staging/releases'. (xx.xxx.x.xxx)
--> `git' could not be found in the path (xx.xxx.x.xxx)
--> `/var/www/xx.xxx.x.xxx_staging/shared' is not writable (xx.xxx.x.xxx)
我已经用谷歌搜索了很长时间,但无法解决这个问题。由于我对此完全陌生,并且觉得学习创建 Rails 应用程序和了解有关部署它们的所有事情之间存在巨大差距(顺便说一句:早期的 ftp 上传发生了什么?),我真的希望有人知道如何解决这个问题,并可以引导我走向一个不那么陡峭的部署学习曲线。顺便说一句:有没有“更简单”的方法来做我想做的事情?非常感谢!
编辑:还有一个问题:我真的需要在 github 上部署应用程序以到达服务器吗?
【问题讨论】:
-
Ryan Bates 在deploying to a vps 上有一个出色的 Railscast,不幸的是它不是免费的,但我强烈推荐它。他涵盖了您需要做的所有事情。
-
感谢您的建议,但实际上我观看了有关 vps / capistrano 的 railscasts 但我仍然无法理解,因为设置太多而且我不知道其中哪些是相关的。
-
好的,让我们一点一点地分解它以使其更容易。不要跳入深渊,让您的第一个部署运行需要一些时间 首先,我建议您跳过执行不同的登台和生产服务器,并从直接部署到生产开始。一旦你开始运行,你就可以开始修改以包括登台。我将在下面的答案中解释 Railscasts 中使用的 Capistrano 脚本。用它作为你的模板
-
提前非常非常感谢您!
标签: ruby-on-rails deployment capistrano