zlib is missing; necessary for building libxml2 とのログ出力内容から、zlib 関連のライブラリや libxml2 が利用できないのであろうと想定がつきますが、zlib がインストールされていても発生するので zlib 以外にも必要なパッケージをインストールしておく必要があります。
事象
# gem install nokogiri
Fetching: mini_portile2-2.0.0.gem (100%)
Successfully installed mini_portile2-2.0.0
Fetching: nokogiri-1.6.7.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.0.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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}/lib64
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
Gem files will remain installed in /usr/local/share/gems/gems/nokogiri-1.6.7 for inspection.
Results logged to /usr/local/share/gems/gems/nokogiri-1.6.7/ext/nokogiri/gem_make.out
対策
CentOS 7.x では、zlib-devel パッケージが入っていないと上記のようなエラーとなるようです。
必要となるパッケージをインストールしてから gem install nokogiri するとうまくいくはずです。
# yum install zlib zlib-devel libxml2 -y
結果
# gem install nokogiri
Successfully installed nokogiri-1.6.7ld take a while...
Parsing documentation for nokogiri-1.6.7
Installing ri documentation for nokogiri-1.6.7
1 gem installed