nokogiriのインストールエラー

nokogiriのインストールに2回つまずきました。

『gem install rails』での下記のようなエラー

Fetching: nokogiri-1.6.6.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
	ERROR: Failed to build gem native extension.

    /home/vagrant/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20150519-20209-p4k4pv.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
	- 0001-Revert-Missing-initialization-for-the-catalog-module.patch
	- 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************

これには

sudo yum -y install libxml2 libxslt libxml2-devel libxslt-devel
gem install nokogiri -- --use-system-libraries

ライブラリを入れることで解決できました。

 

次に『bundle install』でのエラー

An error occurred while installing nokogiri (1.6.6.2), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.6.6.2'` succeeds before bundling.

これには

bundle config build.nokogiri --use-system-libraries

を指定することで解決。