[英]Deploying Rails-application on Ubuntu server using Capistrano gem
I try to deploy my rails application on local virtual machine which runs ubuntu 14 LTS. 我尝试将Rails应用程序部署在运行ubuntu 14 LTS的本地虚拟机上。 I use nginx and phusion passenger. 我使用Nginx和Phusion乘客。 Also, I use capistrano gem for deployment. 另外,我使用capistrano gem进行部署。
I added my local ssh key to virtual machine's authorized keys. 我将本地ssh密钥添加到虚拟机的授权密钥中。
Also i have no problem connecting to my virtual machine via ssh like that: 我也没有问题通过ssh连接到我的虚拟机,像这样:
ssh neil@192.168.0.8 ssh尼尔@ 192.168.0.8
However when I write: 但是当我写:
bundle exec cap production deploy
I get the following error: 我收到以下错误:
cap aborted!
Net::SSH::Disconnect: connection closed by remote host
EOFError: end of file reached
Tasks: TOP => rbenv:validate
My deploy.rb file: 我的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
My deploy/production.rb file: 我的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)
My nginx.conf file: 我的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;
}
Change production.rb like this, 像这样更改production.rb,
role :app, 'address_of_the_server', {
:ssh_options => {
:keys => 'key_path(like ~/.ssh/key_name.pem)'
}
}
role :web, 'address_of_the_server', {
:ssh_options => {
:keys => 'key_path(like ~/.ssh/key_name.pem)'
}
}
role :db, 'address_of_the_server', {
:ssh_options => {
:keys => 'key_path(like ~/.ssh/key_name.pem)'
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.