我第一次尝试不是将 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 上部署应用程序到服务器吗?