インストール
Ruby は別記事を参考にして最新をインストールします。
CentOSに最新のRubyをインストールする手順 | 田舎に住みたいエンジニアの日記
最新で無い場合は、gemのバージョンに合わせて、Capistranoもインストールできるバージョンが違うので注意が必要です。
gemでサクッとインストールします。
# /usr/local/bin/gem install capistrano Fetching: net-ssh-2.9.1.gem (100%) Successfully installed net-ssh-2.9.1 Fetching: net-scp-1.2.1.gem (100%) Successfully installed net-scp-1.2.1 Fetching: colorize-0.7.3.gem (100%) Successfully installed colorize-0.7.3 Fetching: sshkit-1.5.1.gem (100%) Successfully installed sshkit-1.5.1 Fetching: i18n-0.7.0.beta1.gem (100%) Successfully installed i18n-0.7.0.beta1 Fetching: capistrano-3.2.1.gem (100%) Capistrano 3.1 has some breaking changes, like `deploy:restart` callback should be added manually to your deploy.rb. Please, check the CHANGELOG: http://goo.gl/SxB0lr If you're upgrading Capistrano from 2.x, we recommend to read the upgrade guide: http://goo.gl/4536kB Successfully installed capistrano-3.2.1 Parsing documentation for capistrano-3.2.1 Installing ri documentation for capistrano-3.2.1 Parsing documentation for colorize-0.7.3 Installing ri documentation for colorize-0.7.3 Parsing documentation for i18n-0.7.0.beta1 Installing ri documentation for i18n-0.7.0.beta1 Parsing documentation for net-scp-1.2.1 Installing ri documentation for net-scp-1.2.1 Parsing documentation for net-ssh-2.9.1 Installing ri documentation for net-ssh-2.9.1 Parsing documentation for sshkit-1.5.1 Installing ri documentation for sshkit-1.5.1 Done installing documentation for capistrano, colorize, i18n, net-scp, net-ssh, sshkit after 14 seconds 6 gems installed
バージョンを確認
# /usr/local/bin/cap --version Capistrano Version: 3.2.1 (Rake Version: 10.1.0)
以上となります。capistranoはgemだけ入ってれば簡単にできちゃいます。
ちなみに、他のサーバにも配る場合には、 gem install capistrano-ext も必要です。
gem install したcapistoranoのバージョンを2に変更したい
現在のcapistoranoのバージョンをアンインストールします。
# /usr/local/bin/gem uninstall -v 3.2.1 capistrano Remove executables: cap, capify in addition to the gem? [Yn] Y Removing cap Removing capify Successfully uninstalled capistrano-3.2.1
capistrano2系をインストールする
# gem install capistrano -v 2.5.5
2,5,5になりました。しかし、opensshのエラーが発生しました。
Net::SSH::AuthenticationFailed: Authentication failed for user xxxxxxx
このエラーをなくしましょう。net-ssh を2.9から2.6にしてみます。
# gem uninstall -v 2.9.1 net-ssh You have requested to uninstall the gem: net-ssh-2.9.1 capistrano-2.5.5 depends on [net-ssh (>= 2.0.10)] net-scp-1.2.1 depends on [net-ssh (>= 2.6.5)] net-sftp-2.1.2 depends on [net-ssh (>= 2.6.5)] net-ssh-gateway-1.2.0 depends on [net-ssh (>= 2.6.5)] sshkit-1.5.1 depends on [net-ssh (>= 2.8.0)]
こんな感じで依存関係があるようです。しかし、削除。そして再インストールします。
gem install net-ssh -v 2.6.5
これで完了。capistrano2も動作するようになりました。
[amazonjs asin=”4774164283″ locale=”JP” title=”チーム開発実践入門 ~共同作業を円滑に行うツール・メソッド (WEB+DB PRESS plus)”]