新手问题 [已解决] Capistrano 用户验证问题?

chairy11 · 发布于 2014年11月19日 · 最后由 chenge 回复于 2015年03月25日 · 4758 次阅读
827

问题

在我的理解里,我在自己的app代码中部署好了capistrano , 输入

cap production deploy:setup

然后它提示我输入密码,应该就搞定了……

可事实是,它没让我输入密码,直接就提示我

DEBUG[dd17face] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxxx.xxxx.xx
DEBUG[dd17face] Command: [ -d ~/.rvm ]
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on hostxxx.xxxx.xxxx.xx
: Authentication failed for user root@xxx.xxxx.xxxx.xx


Net::SSH::AuthenticationFailed: Authentication failed for user root@xxx.xxxx.xxxx.xx

Tasks: TOP => rvm:hook

怎么破?

后来,我就在config/environments/production.rb中加了一句

set :password, ask('Server password:', nil)
server 'server.domain.com', user: 'ssh_user_name', port: 22, password: fetch(:password), roles: %w{web app db}

它倒是问我密码了,可是竟然明文显示密码,这就算了,结果还是搞不定,显示的结果是:

$ cap production deploy:setup        

Please enter Server password (): xxxx
DEBUG[5db14c73] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxxx.xxxx.xx

DEBUG[ab50c1ba] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxxx.xxxx.xx

DEBUG[ab50c1ba] Command: [ -d ~/.rvm ]
DEBUG[5db14c73] Command: [ -d ~/.rvm ]
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxxx.xxxx.xx
: connection closed by remote host

Net::SSH::Disconnect: connection closed by remote host

EOFError: end of file reached

Tasks: TOP => rvm:hook
(See full trace by running task with --trace)

难道会是我的rvm地址没设置对吗?

好吧,目前我正在研究这个文档

解决方案

增加从本机到服务器的SSH

# Mac OSX 上 ssh-copy-id不是默认安装的,可通过Homebrew进行安装
    brew install ssh-copy-id

#  将私钥加入ssh-agent管理:
     ssh-add ira                                       # (注:ira指的是私钥名称)

# 公钥加到远程服务器
      ssh-copy-id -i ~/.ssh/yby.pub root@xxx.xxx.xxx.xxx
共收到 22 条回复
9442

建议先学习配置ssh连接自己服务器,github,bitbucket. 再回头就简单多了。

14793

在服务器中加入本机的key

来自RubyChina4Android

827

#2楼 @flowerwrong 我平时push代码到github,bitbucket都是用SSH的。服务器之前pull代码也是用SSH通过验证的。不过我没试过从自己机子到服务器用SSH,我折腾下……

827

#3楼 @bestjane #2楼 @flowerwrong 已经在服务器加上我本机的SSH KEY,因为我现在输入 ssh root@xxx.xxx.xxx.xxx,不用密码就能直接进入服务器了。 可是,运行

cap production deploy:check

会出现

DEBUG[9b8c96d0] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxx.xxx.xxx
DEBUG[9b8c96d0] Command: [ -d ~/.rvm ]
DEBUG[9b8c96d0] Finished in 25.961 seconds with exit status 1 (failed).
DEBUG[2447555d] Running /usr/bin/env [ -d /usr/local/rvm ] on xxx.xxx.xxx.xxx
DEBUG[2447555d] Command: [ -d /usr/local/rvm ]
DEBUG[2447555d] Finished in 6.133 seconds with exit status 0 (successful).
DEBUG[7985b73b] Running /usr/local/rvm/bin/rvm version on xxx.xxx.xxx.xxx
DEBUG[7985b73b] Command: /usr/local/rvm/bin/rvm version
DEBUG[7985b73b]     rvm 1.25.34 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG[7985b73b] Finished in 7.365 seconds with exit status 0 (successful).
rvm 1.25.34 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG[dcd2a0bb] Running /usr/local/rvm/bin/rvm current on xxx.xxx.xxx.xxx
DEBUG[dcd2a0bb] Command: /usr/local/rvm/bin/rvm current
DEBUG[dcd2a0bb]     ruby-2.1.2
DEBUG[dcd2a0bb] Finished in 7.068 seconds with exit status 0 (successful).
ruby-2.1.2
DEBUG[b8c3e406] Running /usr/local/rvm/bin/rvm 2.1.2p95 do ruby --version on xxx.xxx.xxx.xxx
DEBUG[b8c3e406] Command: /usr/local/rvm/bin/rvm 2.1.2p95 do ruby --version
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xxx: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Nothing written

SSHKit::Command::Failed: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Nothing written

Tasks: TOP => rvm:check

没看懂这是哪里出错了……

9442

昨天听你说你的gemfile.lock里面cap是2,你把他删掉,重新重新bundle install 试下

rm Gemfile.lock
bundle install

git@github.com:FlowerWrong/capdemo.git

827

#6楼 @flowerwrong 我本机的已经是cap 3了。服务器的我这两天commit的没有更新,那看来我在第一次用cap之前,还是得先手动更新下次? 我现在进服务器手动git pull最新代码了。

9442

手动git pull最新代码 不用,cap production deploy:check 会创建基础环境,过后cap production deploy 要不先玩这个demo吧 git@github.com:FlowerWrong/capdemo.git

# https://github.com/FlowerWrong/capdemo/blob/master/config/deploy.rb
set :deploy_to, '/home/ubuntu/www/capdemo'
# https://github.com/FlowerWrong/capdemo/blob/master/config/deploy/production.rb
role :app, %w{ubuntu@xxx}
role :web, %w{ubuntu@xxx}
role :db, %w{ubuntu@2xxx}
# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server definition into the
# server list. The second argument is a, or duck-types, Hash and is
# used to set extended properties on the server.
server 'xxx', user: 'ubuntu', roles: %w{web app}, my_property: :my_value
827

#8楼 @flowerwrong 不懂怎么玩啊。反正我现在按说服务器里刚已经 git pull , 并 bundle install ,已经用了cap 3了。我还touch tmp/restart.txt,如果平时手动更新也就这么个步骤了吧?

但还是同样出错。

$ cap production deploy:check --trace


** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:hook (first_time)
** Execute rvm:hook
DEBUG[e614ad80] Running /usr/bin/env [ -d ~/.rvm ] on xxx.xxx.xxx.xxx
DEBUG[e614ad80] Command: [ -d ~/.rvm ]
DEBUG[e614ad80] Finished in 5.743 seconds with exit status 1 (failed).
DEBUG[ad2818c3] Running /usr/bin/env [ -d /usr/local/rvm ] on xxx.xxx.xxx.xxx
DEBUG[ad2818c3] Command: [ -d /usr/local/rvm ]
DEBUG[ad2818c3] Finished in 1.495 seconds with exit status 0 (successful).
** Invoke rvm:check (first_time)
** Execute rvm:check
DEBUG[88e3ae89] Running /usr/local/rvm/bin/rvm version on xxx.xxx.xxx.xxx
DEBUG[88e3ae89] Command: /usr/local/rvm/bin/rvm version
DEBUG[88e3ae89]     rvm 1.25.34 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG[88e3ae89] Finished in 1.899 seconds with exit status 0 (successful).
rvm 1.25.34 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG[ef7d1ca6] Running /usr/local/rvm/bin/rvm current on xxx.xxx.xxx.xxx
DEBUG[ef7d1ca6] Command: /usr/local/rvm/bin/rvm current
DEBUG[ef7d1ca6]     ruby-2.1.2
DEBUG[ef7d1ca6] Finished in 1.519 seconds with exit status 0 (successful).
ruby-2.1.2
DEBUG[8e5f9ffa] Running /usr/local/rvm/bin/rvm 2.1.2p95 do ruby --version on xxx.xxx.xxx.xxx
DEBUG[8e5f9ffa] Command: /usr/local/rvm/bin/rvm 2.1.2p95 do ruby --version
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xxx: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Nothing written
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:77:in `capture'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:11:in `block (3 levels) in <top (required)>'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
SSHKit::Command::Failed: ruby exit status: 2
ruby stdout: Nothing written
ruby stderr: Nothing written
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:77:in `capture'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:11:in `block (3 levels) in <top (required)>'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/yebiying/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => rvm:check

9442
require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/rvm' # 看下是不是没有加入rvm
# require 'capistrano/rbenv'
# require 'capistrano/chruby'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'

Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
827

是capfile吧?加了的

# Load DSL and Setup Up Stages
require 'capistrano/setup'

# Includes default deployment tasks
require 'capistrano/deploy'

# Includes tasks from other gems included in your Gemfile
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano/passenger'


# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

但deploy.rb中,

# set :rvm_type, :system                     # Defaults to: :auto
set :rvm_ruby_version, '2.1.2p95'
set :rvm_roles, [:app, :web, :db]

在deploy/production.rb中

server 'xxx.xxx.xxx.xxx',
       user: 'root',
       roles: %w{web app},
       ssh_options: {
           user: 'root', # overrides user setting above
           keys: %w(/Users/yebiying/.ssh/yby),
           forward_agent: false,
           auth_methods: %w(publickey password)
          # password: 'please use keys'
        }

主要我还是没看出是哪里有错,

SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xxx: ruby exit status: 2

好像都google不到status:2 是指什么……

827

#10楼 @flowerwrong 请教一下,deploy/production.rb中

server 'xxx.xxx.xxx.xxx',
       user: 'root',
       roles: %w{web app},
       ssh_options: {
           user: 'root', # overrides user setting above
           keys: %w(/Users/yebiying/.ssh/yby),
           forward_agent: false,
           auth_methods: %w(publickey password)
          # password: 'please use keys'
        }

那个keys , 是写的本机的私钥的地址,还是服务器中publickey的地址?

9442

#12楼 @chairy11 部署到一台服务器一般不用写server那部分 server 'xxx', user: 'root', roles: %w{web app}, my_property: :my_value 就可以了

地址是你本机的私钥地址

# server 'example.com',
#   user: 'user_name',
#   roles: %w{web app},
#   ssh_options: {
#     user: 'user_name', # overrides user setting above
#     keys: %w(/home/user_name/.ssh/id_rsa),
#     forward_agent: false,
#     auth_methods: %w(publickey password)
#     # password: 'please use keys'
#   }

~/.ssh/config

Host bitbucket.org
  User flowerwrong
    Hostname bitbucket.org
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_bitbucket

Host github.com
  User flowerwrong
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_github

Host ip
  IdentityFile ~/.ssh/id_rsa_xx

827

#13楼 @flowerwrong 终于前进了一点点。 现在发现之前的两三个小问题,一个是

set :rvm_custom_path, '/usr/local/rvm'  # only needed if not detected

而我本来的地址可能写的不对,写了"/usr/local/rvm/bin/rvm"

另一个是

set :rvm_ruby_version, '2.1.2'      # Defaults to: 'default'

我原来写的是 '2.1.2p95'

现在提示的新问题是:

ERRORlinked file /var/www/weekly.com/shared/config/database.yml does not exist on xxx.xxx.xxx.xxx
cap aborted!

但哪个放在share难道不应该是capinstrano自己搞的吗?我要自己复制过去?

827

#13楼 @flowerwrong 终于前进了一点点。 现在发现之前的两三个小问题,一个是

set :rvm_custom_path, '/usr/local/rvm'  # only needed if not detected

而我本来的地址可能写的不对,写了"/usr/local/rvm/bin/rvm"

另一个是

set :rvm_ruby_version, '2.1.2'      # Defaults to: 'default'

我原来写的是 '2.1.2p95'

现在提示的新问题是:

ERRORlinked file /var/www/weekly.com/shared/config/database.yml does not exist on xxx.xxx.xxx.xxx
cap aborted!

但哪个放在share难道不应该是capinstrano自己搞的吗?我要自己复制过去?

827

#13楼 @flowerwrong 终于前进了一点点。 现在发现之前的两三个小问题,一个是

set :rvm_custom_path, '/usr/local/rvm'  # only needed if not detected

而我本来的地址可能写的不对,写了"/usr/local/rvm/bin/rvm"

另一个是

set :rvm_ruby_version, '2.1.2'      # Defaults to: 'default'

我原来写的是 '2.1.2p95'

现在提示的新问题是:

ERRORlinked file /var/www/weekly.com/shared/config/database.yml does not exist on xxx.xxx.xxx.xxx
cap aborted!

但哪个放在share难道不应该是capinstrano自己搞的吗?我要自己复制过去?

827

#13楼 @flowerwrong
另外,my_property: :my_value,这句是干什么的? 我不知道从哪抄了句:

server 'xxx.xxx.xxx.xxx', user: 'root', roles: %w{web app db}, primary: true

但我也不知道primary: true是干什么的……

96

看看cap执行的什么命令,自己ssh上服务器一条条的敲,看看对不对

827

#13楼 @flowerwrong #18楼 @jimrokliu 现在执行的命令应该是

cap production deploy:check:linked_files

提示的是:

file /var/www/weekly.com/shared/config/database.yml does not exist

我手动复制过去好吗?还是说应该在哪里设置一下的?

827

#13楼 @flowerwrong #18楼 @jimrokliu 额,我手动把database.yml复制到shared下了…… 是复制不是移动,因为rails本身好像是会回到原来的config位置找的,另外设置貌似也有点复制,我就先让它同时存在了,这样好吗?

4215

#21楼 @chairy11 谢谢您的文档,我今天也遇到了。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册