步驟1:中的Gemfile
gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-rails'
步驟2:束
第3步:cap install
##就會生成設定文件的
第4步:去Capfile
並粘貼以下代碼##該文件將平行於Rails應用程序
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
步驟5:配置/ deploy.rb,這將是通用於ENV
該文件將被共享/通用跨應用環境
set :application, 'your_app' ## keep in mind that your app dir name will be your_app
set :repo_url, '[email protected]:somerepo/code.git'
set :branch, 'master'
set :use_sudo, true
set :deploy_to, '/public_html/test'
set :linked_files, fetch(:linked_files, []).push('config/database.yml')
set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
第六步:我們創建ENV特定的文件,現在對於生產環境
config/deploy/production.rb
##這個文件將被生成cap install
這個時候你以前沒有必要的命令
請注意除此以外的所有代碼
role :app, %w{8.8.8.8:6554}
set :ssh_options, {
user: 'User'
}
步驟6:現在做ssh to your server
ssh [email protected]:6554
現在它會要求輸入密碼...give password
第7步:現在默認的程序將會/var/www/app
,在這裏你需要相應地,但在你的情況下創建的文件夾,你set :deploy_to, '/public_html/test'
#確保目錄名稱後跟/「正斜槓」這個錯誤我做了很多次
sudo mkdir -p /public_html
sudo mkdir -p /public_html/test
sudo chown User:User /public_html/test # `chown` will change the owner ship so that `User` user can `**Read/Write**`
umask 0002
mkdir /public_html/test/releases ## these are convention
mkdir /public_html/test/shared ## these are convention
sudo chown User:User public_html/test/releases
sudo chown User:User public_html/test/shared
mkdir .ssh
chmod .ssh 007
ssh-keygen -t rsa
and follow the step ## this will generate ssh key
cat .ssh/id_rsa.pub
現在加上這關鍵看你的回購的進入=>設置=>部署鍵按鈕=>點擊那個和添加Key
。把標籤命名爲任何你想要的東西,並粘貼ssh key
在這裏。
那它從服務器側
第八步:現在,您需要將您的SSH密鑰添加到服務器 對於做cat ~/.ssh/id_rsa.pub
如果你有rsa
鍵其他明智的產生RSA密鑰是很容易到箱子
步驟9:登錄到服務器使用ssh
`vi .ssh/authorized_keys` and paste your local machine rsa key
保存並退出
步驟10:cap -T
##列出所有任務
步驟11:cap production deploy:check
因爲database.yml文件,是不是會引發錯誤there
對於那vi /public_html/test/shared/config/database.yml
development:
adapter: postgresql
database: testdb_cap
pool: 5
timeout: 5000
保存並退出
再做cap production deploy:check
這一次也不會引發任何錯誤
步驟12:
cap production deploy
,這就是它
請檢查這個ruby rake task after deploymewnt
請幫助別人。我今天需要部署這個。 – 2015-03-03 08:09:26