1.安装SVN客户端
2.安装TortoiseSVN
3.安装SSH
开始:
1.安装Capistrano(最新版为2.5.X)
gem install Capistrano
2.进入你的rails app 的上一层目录,生成对Capistrano的支持
capify rails_name
rails_name为你的rails app的名字
3.进入rails app的目录,修改生成的Capfile,让其为:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } load 'config/deploy' default_run_options[:pty] = true
4.修改生成的config/deploy.rb:(含[]号的内容需替换为相关参数)
set :application, "[your_app_name]" #[your_app_name]为你的rails app名字 set :repository, "svn+ssh://[user_name]@[your_domain_name]/home/[user_name]/[your_repository_path]" #[user_name]:你的用户名 , [your_domain_name]:你的域名, [your_repository_path]:你的SVN仓库名 set :user, "[user_name]" set :domain, "[your_domain_name]" set :scm_command, "/home/[user_name]/bin/svn" set :local_scm_command, :default # If you aren't deploying to /u/apps/#{application} on the target # servers (which is the default), you can specify the actual location # via the :deploy_to variable: set :deploy_to, "/home/[user_name]/[deploy_root]/#{application}" #[deploy_root]:要部署的目的目录 # If you aren't using Subversion to manage your source code, specify # your SCM below: # set :scm, :subversion role :app, "#{domain}" role :web, "#{domain}" role :db, "#{domain}", :primary => true
可参考:http://www.bluehostforum.com/showthread.php?p=48891
5.让svn通过TortoisePlink连接host主机.
找到svn配置文件(一般是C:\Documents and Settings\[用户名]\Application Data\Subversion目录下的config文件)
找到[tunnels],在其下文加入
ssh = C:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe -ssh -l [ssh_user_name] -pw [ssh_password] #C:\\Program Files\\TortoiseSVN为本人TortoiseSVN的安装目录,[ssh_user_name]为你的登陆SSH的用户名,[ssh_password]为密码
6.在你的rails app的目录下执行命令,按提示输入密码即可
cap deploy