【发布时间】:2016-04-11 22:03:30
【问题描述】:
我尝试在运行 ubuntu 14 LTS 的本地虚拟机上部署我的 rails 应用程序。我使用 nginx 和 phusion 乘客。另外,我使用 capistrano gem 进行部署。
我将本地 ssh 密钥添加到虚拟机的授权密钥中。
我也可以像这样通过 ssh 连接到我的虚拟机:
ssh neil@192.168.0.8
但是当我写的时候:
bundle exec cap production deploy
我收到以下错误:
cap aborted!
Net::SSH::Disconnect: connection closed by remote host
EOFError: end of file reached
Tasks: TOP => rbenv:validate
我的 deploy.rb 文件:
server "192.168.0.8", port: 80, roles: %i(:web :app :db), primary: true
set :log_level, :debug
set :application, "mySimpleBlog"
set :repo_url, "git@github.com:NeilAlishev/mySimpleBlog.git"
set :user, "neil"
set :linked_files, fetch(:linked_files, []).push("config/database.yml", "config/secrets.yml")
set :linked_dirs, fetch(:linked_dirs, []).push("log", "tmp/pids", "tmp/cache", "tmp/sockets",
"vendor/bundle", "public/system", "public/uploads")
set :deploy_to, "/home/#{fetch(:user)}/src/#{fetch(:application)}"
set :rbenv_type, :user
set :rbenv_ruby, "2.2.4"
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} "\
"RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w(rake gem bundle ruby rails)
set :rbenv_roles, :all
namespace :deploy do
desc "Restart application"
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join("tmp/restart.txt")
end
end
after :publishing, "deploy:restart"
after :finishing, "deploy:cleanup"
end
我的 deploy/production.rb 文件:
set :stage, :production
server "192.168.0.8", user: "neil", roles: %w(web app db)
role :app, %w(neil@192.168.0.8)
role :web, %w(neil@192.168.0.8)
role :db, %w(neil@192.168.0.8)
我的 nginx.conf 文件:
server {
listen 80;
server_name 192.168.0.8;
charset utf-8;
rails_env production;
passenger_enabled on;
root /home/neil/mySimpleBlog/current/public;
}
【问题讨论】:
-
你可以试试this thread中的解决方案吗?
-
您确定可以通过 SSH 连接到目标服务器吗?
-
当我输入 ssh neil@address_of_the_server 时,我可以毫无问题地访问服务器。
-
您的问题解决了吗?我也有同样的问题。
cap production deploy时,我可以连接到机器但与您有同样的错误
标签: ruby-on-rails ruby ubuntu nginx ssh