Red Hat / CentOS
The easiest way to get Nokogiri installed on CentOS and RHEL seems to be the EPEL repository which contains a prebuilt nokogiri package. To use it, install the appropriateepel-release package for your OS, then run:
sudo yum install -y rubygem-nokogiri
To install using gem install is somewhat more complicated because of the age of the packages available from the central repositories. If you have rubygems installed, you may be able to install nokogiri viagem install
. If you run intro problems, try installing these packages as well.
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
CentOS 5 (and RHEL5) come installed with libxml 2.6.26 which, while not as offensively out-of-date as Mac Leopard, is still pretty damn old (released June 2006) and has known issues.
If you’re affected by any known bugs or are seeing odd behavior, you may want to consider uninstalling the RPMs for libxml2 and libxslt, and building them from source.
sudo yum remove -y libxml2-devel libxslt-devel
- download the most recent libxml2 and libxslt from ftp://xmlsoft.org/libxml2/
./configure ; make ; sudo make install
Then install nokogiri specifying the libxml2 and libxslt install directories:
sudo gem install nokogiri -- --with-xml2-lib=/usr/local/lib
--with-xml2-include=/usr/local/include/libxml2
--with-xslt-lib=/usr/local/lib
--with-xslt-include=/usr/local/include
(Note that, by default, libxslt header files are installed into the root include directory, but libxml2 header files are installed into a subdirectory thereof namedlibxml2
.)
Or, you know, whatever directories into which you installed libxml and libxslt. Good luck.
http://nokogiri.org/tutorials/installing_nokogiri.html