gem install时报错,no such file to load — zlib (解决方案)

通过ruby 的gem install安装时,经常会遇到的错误

[root@localhost zlib]# gem install rails
    ERROR:  Loading command: install (LoadError)
    cannot load such file -- zlib
    ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass
---------------------------------------------------------------------------
终极解决方案:最小化安装系统通用:
[root@bogon ~]# yum install  vim iotop bc gcc gcc-c++ glibc glibc-devel pcre \
pcre-devel openssl  openssl-devel zip unzip zlib-devel  net-tools \
lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel \
bc  systemd-devel bash-completion traceroute -y
---------------------------------------------------------------------------
解决方案:
进入ruby源码文件夹 
安装ruby自身提供的zlib包 
#cd ext/zlib
#ruby ./extconf.rb
#make
#make install
问题解决
----------------------------------------------------------------------------
附上另外一个错误的解决方案
--with-openssl-include=/usr/local/ssl/include/ --with-openssl-lib=/usr/local/ssl/lib  
也是一样的处理思路:
# cd ext/openssl
# ruby ./extconf.rb
# make
# make instal