Ruby1.9.3をインストールしたときのいろいろなエラー

EC2で新しく環境構築して、Ruby1.9.3をソースからコンパイルしてgemをアップデートしようとしたら以下のエラーが出た。

[root@hoge ~]# gem update --system
/usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
ERROR:  Loading command: update (LoadError)
    cannot load such file -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::UpdateCommand

とりあえず、yumで以下を入れる。

yum install zlib-devel

再度Rubyコンパイルをして確認

[root@hoge ~]# gem update --system
/usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

エラーは出なくなったけど、警告がまだ消えない。
以下からソースファイルを持ってきてコンパイル
http://pyyaml.org/wiki/LibYAML
http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz


んで、再度Rubyコンパイルしたらうまくいきました。
が、passengerをインストールしようとしたらこんなエラーが、、

                                                                                      • -
Checking for required software... * GNU C++ compiler... found at /usr/bin/g++ * Curl development headers with SSL support... found * OpenSSL development headers... found * Zlib development headers... found * Ruby development headers... found * OpenSSL support for Ruby... not found * RubyGems... found * Rake... found at /usr/local/bin/rake * rack... found * Apache 2... found at /usr/sbin/httpd * Apache 2 development headers... found at /usr/sbin/apxs * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config Some required software is not installed. But don't worry, this installer will tell you how to install them. Press Enter to continue, or Ctrl-C to abort.
                                                                                      • -

OpenSSL...ぬぬ、、以下を入れる。

yum -y install httpd-devel
yum -y install openssl-devel

再度Rubyコンパイルで無事完了

結論

Ruby1.9.3を素のAmazon Linuxにソースからインストールする場合は、まず以下を実行するべし

yum -y install gcc
yum -y install make
yum -y install gcc-c++
yum -y install zlib-devel
yum -y install httpd-devel
yum -y install openssl-devel
yum -y install curl-devel

これできっと幸せになれるはず

[追伸]
Rubyコンパイルを何度もやり直したのだが、最初はmicroインスタンスだったんだけど、時間かかりすぎるので、以降はxlargeにして作業してました


参考URL
http://d.hatena.ne.jp/donbulinux/20111111/1321004527