ec2onrails本編
http://ec2onrails.rubyforge.org/
5. Copy your public key from the server to keep Capistrano happy
config/deploy.rb、config/s3.ymlの中身をきちんと書く時が来たようだ。
s3.ymlとdeploy.rbをだいたい書いた。(access key とかec2のホスト名だとか、すごくわかりやすい箇所。ってそれを書いておかないと後でたぶん困る。)
deploy.rb------
ssh_options[:keys] = ["#{ENV['HOME']}/.ssh/id_rsa-gsg-keypair"]
と書いて
$ cap ec2onrails:get_public_key_from_server
* executing `ec2onrails:get_public_key_from_server'
Your first key in ssh_options[:keys] is /Users/code/.ssh/id_rsa-gsg-keypair, presumably that's
your EC2 private key. The public key will be copied from the server
named 'ec2-11-111-11-111.compute-1.amazonaws.com' and saved locally as /Users/code/.ssh/id_rsa-gsg-keypair.pub. Continue? [y/n]
y
authorized_keys 100% 393 0.4KB/s 00:01
6. Deploy the app with Capistrano
$ cap ec2onrails:setup
ubuntu関係の諸々がec2マシンへインストールされていく。
しばしログが流れる。
rmagick関連でエラーが出た。
* executing `ec2onrails:server:install_gems'
* executing "sudo -p 'sudo password: ' gem install rmagick --no-rdoc --no-ri"
servers: ["ec2-11-111-11-111.compute-1.amazonaws.com"]
[admin@ec2-11-111-11-111.compute-1.amazonaws.com] executing command
Updating metadata for 326 gems from http://gems.rubyforge.org/
.
.
.
.
.
.
.
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb install rmagick --no-rdoc --no-ri
checking for Ruby version >= 1.8.2... yes
checking for cc... yes
checking for Magick-config... no
Can't install RMagick 2.5.2. Can't find Magick-config in /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.8
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/rmagick-2.5.2 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/rmagick-2.5.2/ext/RMagick/gem_make.out
complete
Building native extensions. This could take a while...
command finished
command "sudo -p 'sudo password: ' gem install rmagick --no-rdoc --no-ri" failed on admin@ec2-11-111-11-111.compute-1.amazonaws.com
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
RMagick 2.5.2 のインストールに失敗したよ。
というのもMagick-config が /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/binのどこにも見当たらないから。
extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.8
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
rmagickはすぐには使わないから後でインストールすることにしよう。
config/deploy.rb
-
-
-
- -
-
-
# :packages => ["logwatch", "imagemagick"],
:packages => ["logwatch"],
# :rubygems => ["rmagick"],
:rubygems => [],
-
-
-
- -
-
-
database.yml に問題あり、とのご指摘。
* executing `ec2onrails:db:load_config'
/opt/local/lib/ruby/gems/1.8/gems/ec2onrails-0.9.9/lib/ec2onrails/recipes.rb:179: ERROR: missing database config. Make sure database.yml contains a 'production' section with either 'host: hostname' or 'socket: /var/run/mysqld/mysqld.sock'. (RuntimeError)
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/configuration/execution.rb:127:in `instance_eval'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/configuration/execution.rb:127:in `invoke_task_directly_without_callbacks'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/configuration/callbacks.rb:27:in `invoke_task_directly'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/configuration/execution.rb:80:in `execute_task'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/configuration/namespaces.rb:186:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/configuration/namespaces.rb:186:in `method_missing'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/configuration/namespaces.rb:186:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/configuration/namespaces.rb:186:in `method_missing'
... 22 levels...
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/cli/execute.rb:14:in `execute'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/bin/cap:4
from /opt/local/bin/cap:19:in `load'
from /opt/local/bin/cap:19
-
-
- -
-
config/database.yml
SQLite version 3.x
# gem install ec2-11-111-11-1.compute-1.amazonaws.com (not necessary on OS X Leopard)
(略)
production:
adapter: sqlite3
database: db/production.sqlite3
timeout: 5000
いつもmysqlなのでsqlite3の場合の書き方がわからん。
ひとまずsqlite3-rubyを入れるか、と思ったけど、ここで小休憩。。。
database.ymlをmysql用の書き方にして、
DBのパスワードはこちらの値を一緒にして
(DBのusernameはrootのまま)
config/deploy.rb
:mysql_root_password => "xxxxxxx",
再度実行したら
$ cap ec2onrails:setup
無事完了した。
残課題:imagemagick、rmagickをまだinstallしていないこと。
ーーーーー
さらに前に進みます。
$ cap deploy:cold
* executing `deploy:cold'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27: command not found: svn info http://svn.foo.com/svn/bookshelf/trunk -rHEAD
[deploy:update_code] rolling back
* executing "rm -rf /mnt/app/releases/2008xxxxxxxxxx; true"
servers: ["ec2-11-111-11-111.compute-1.amazonaws.com"]
[ec2-11-111-11-111.compute-1.amazonaws.com] executing command
command finished
/opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/recipes/deploy/scm/subversion.rb:58:in `query_revision': tried to run `svn info http://svn.foo.com/svn/bookshelf/trunk -rHEAD' and got unexpected result "" (RuntimeError)
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/recipes/deploy/scm/base.rb:35:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/capistrano-2.4.3/lib/capistrano/recipes/deploy/scm/base.rb:35:in `
そう、config/deploy.rbでのscmの設定をしていない。
ソースリポジトリが必須ということか。そりゃそうなんだけど。
どこに用意するか。。。。