# 在redhat 内核中不需要sudo 方式运行。 set :use_sudo, false # Do not use sudo ro run command. set :domain, 'www.firebirds.com' set :application, 'ruby_on_rails' set :user, 'root' # connect to server use this variable. # 连接app服务器,并执行命令 set :repository, "svn://172.10.12.8/www/ror/trunk" set :port, 8888 # connect server use ssh with this port# ssh连接app服务器的端口号. set :deploy_to, "/var/www/ror" # deploy to server location # set :scm, :subversion set :scm_username, 'xxx' set :scm_password, proc{Capistrano::CLI.password_prompt('SVN pass:')} # 在出现SVN pass: 时输入svn密码. # 在第一次用过后,svn shell会记住此密码,下次可不用。 # control mongrel_cluster #require 'mongrel_cluster/recipes' #set :mongrel_conf, "/etc/mongrel_cluster/spare.yml" role :app, "172.10.12.8" role :web, "172.10.12.8" role :db, "172.10.12.8", :primary => true # app, web, db 都 在同一台机器上如下即可 #server "172.10.12.8", :app, :web, :db, :primary => true set :deploy_via, :export # 在服务器上连接到源码库里去更新 # set :deploy_via, :copy # 在本地打包上传至服务器 set :runner, user # excute command with the front of user defined. # Does not look like you are using the fastcgi processes that reaper is # designed to restart in the setup you described. In your cap script set # them to false. EG set :spinner, "false". See the manual for details. set :spinner, "false" # 使用fascgi 的话,把此行注释 #after 'deploy', 'deploy:cleanup' # hock after deploy #after 'deploy:migrations', 'deploy:cleanup' # hock after deploy:migrations
在用capistrano 进行部署的时候,会希望专用一个web app来管理 这些部署 应用程序如:ccrb 那么ssh 也需要自动登陆出服务器上,如下:但这样不够安全,最好的是不定期的生成ssh密钥; 如: 客户机要想自动登陆到服务器192.168.188.199 上. 1 . 在客户机上制作密钥 2. 把密钥拷至服务器上,追加到.ssh/authorized_keys 文件中.
以下操作在 客户机 上进行
[root@ ~]# ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/root/.ssh/id_dsa): Enter passphrase (empty for no passphrase): # 回车 Enter same passphrase again: # 回车 Your identification has been saved in /root/.ssh/id_dsa. Your public key has been saved in /root/.ssh/id_dsa.pub. The key fingerprint is: ad:85:bddb5:ddr:a544c:fc:ef:57:dd:4b:ef:a9:8a:db root@~ [root@ ~]# cd /root/.ssh/id_dsa id_dsa id_dsa.pub [root@ ~]# scp -P 65534 /root/.ssh/id_dsa.pub [email protected]:/root/.ssh/
在远程服务器上 完成
cd .ssh umask 077 cat ./id_rsa.pub >> authorized_keys
回到客户机上用 ssh 192.168.188.199 -p65534
此时不用输密码即可登陆到服务器上.
http://snippets.dzone.com/tags/rails