Linux に Capistrano をインストールしてサンプルを実行するまで
Capistrano とは?
Ruby で書かれた デプロイツール。
詳細
1. rubyインストール
$ cd /usr/local/src $ wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5.tar.gz $ tar xvfz ruby-1.8.5.tar.gz $ cd ruby-1.8.5.tar.gz $ ./configure $ make $ make test $ sudo make install $ make clean $ ruby -v ruby 1.8.5 (2006-08-25) [i686-linux]
2. gemインストール
$ cd /usr/local/src $ wget http://rubyforge.org/frs/download.php/28174/rubygems-0.9.5.tgz $ tar xvfz rubygems-0.9.5.tgz $ cd rubygems-0.9.5 $ su # ruby setup (省略) As of RubyGems 0.8.0, library stubs are no longer needed. Searching $LOAD_PATH for stubs to optionally delete (may take a while)... ...done. No library stubs found. $ sudo gem -v 0.9.5
3. railsインストール
-
- rails インストール失敗
$ sudo gem install rails --include-dependencies INFO: `gem install -y` is now default and will be removed INFO: use --ignore-dependencies to install only the gems you list ERROR: Error installing rails: rails requires activeresource (= 2.0.0) 参考:Rails' Wiki - ActiveResourceTutorial
-
- ライブラリをインストール
$ sudo gem install activeresource --source http://gems.rubyonrails.org -y INFO: `gem install -y` is now default and will be removed INFO: use --ignore-dependencies to install only the gems you list Bulk updating Gem source index for: http://gems.rubyonrails.org Successfully installed activeresource-2.0.0 1 gem installed Installing ri documentation for activeresource-2.0.0... Installing RDoc documentation for activeresource-2.0.0...
-
- rails インストール成功
$ sudo gem install rails --include-dependencies INFO: `gem install -y` is now default and will be removed INFO: use --ignore-dependencies to install only the gems you list Successfully installed rails-2.0.0 1 gem installed $ rails -v Rails 2.0.0
4. capistoranoインストール
$ sudo gem install capistrano -y INFO: `gem install -y` is now default and will be removed INFO: use --ignore-dependencies to install only the gems you list Updating metadata for 6 gems from http://gems.rubyforge.org ...... complete Successfully installed needle-1.3.0 Successfully installed net-ssh-1.1.2 Successfully installed net-sftp-1.1.0 Successfully installed highline-1.4.0 Successfully installed capistrano-2.1.0 5 gems installed Installing ri documentation for needle-1.3.0... Installing ri documentation for net-ssh-1.1.2... Installing ri documentation for net-sftp-1.1.0... Installing ri documentation for highline-1.4.0... Installing RDoc documentation for needle-1.3.0... Installing RDoc documentation for net-ssh-1.1.2... Installing RDoc documentation for net-sftp-1.1.0... Installing RDoc documentation for highline-1.4.0... $ cap -V Capistrano v2.1.0
5. 弄ってみる
-
- サンプル作成
$ cd /home/someone/capistrano $ vi sample.rb set :application, "tools" set :user, "ユーザー名" set :password, "パスワード" role :local, "localhost" desc "say hello to all hosts" task :foo do run "echo bar @ $HOSTNAME for #{application}" end
-
- サンプル実行
$ cap -f sample.rb foo * executing `foo' * executing "echo bar @ $HOSTNAME for tools" servers: ["localhost"] [localhost] executing command ** [out :: localhost] bar @ ホスト名.localdomain for tools command finished