[root@test50 bin]# ./gem install rails -v=2.3.4
/usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- zlib (LoadError)
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/package.rb:10
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/format.rb:9
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/installer.rb:10
  ... 11 levels...
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:133:in `process_args'
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:104:in `run'
 from /usr/local/ruby/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:58:in `run'
 from ./gem:21
 
 
解决办法:
yum install -y zlib-devel
cd ruby-1.8.6-p287/ext/zlib
/usr/local/ruby/bin/ruby extconf.rb;make;make install
然后就OK了。