Capistrano自动部署Rails项目(Windows到Bluehost Fastdomain)

前提条件:
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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值