在 ubuntu 上安装 nokigiri 很顺利,但是在 CentOS 上安装时各种问题。 使用
gem install nokogiri
安装 nokigiri 的时候回去自动下载 libxml2-2.8.0,而且是从源码安装的,但是报错, 我使用 yum 命令把 libxml2 libxml2-devel libxslt libxslt-devel 安装上后再安装 nokogiri,还是会自动去下载 libxml2-2.8.0 这个包,然后去编译执行,继续报错。 所以我自己把 libxml2-2.8 安装上去了(报错原因是 zlib 版本的问题),终于把 libxml2 给安装上去了,安装时指定的 prefix 是/usr/local/libxml2,所以我使用命令
# gem install nokogiri -- --with-xml2-include=/usr/local/libxml2/include/libxml2/
继续安装(参考的是这个:http://wuhuizhong.iteye.com/blog/1239790) 但是他还是会继续下载 libxml2-2.8.0 这个包,表示很无奈了,求各位谁遇到过这种情况帮下忙,先谢谢各位了。
附上报错信息:
# gem install nokogiri -- --with-xml2-include=/usr/local/libxml2/include/libxml2/
Building native extensions with: '--with-xml2-include=/usr/local/libxml2/include/libxml2/'
This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb --with-xml2-include=/usr/local/libxml2/include/libxml2/
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-redhat-linux/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-redhat-linux/ports/libxml2/2.8.0/compile.log' to see what happened.
*** 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}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-2.0.0-p247/bin/ruby
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/mini_portile-0.5.2/lib/mini_portile.rb:265:in `block in execute': Failed to complete compile task (RuntimeError)
from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `chdir'
from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `execute'
from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/mini_portile-0.5.2/lib/mini_portile.rb:69:in `compile'
from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/mini_portile-0.5.2/lib/mini_portile.rb:109:in `cook'
from extconf.rb:101:in `block in <main>'
from extconf.rb:119:in `call'
from extconf.rb:119:in `block in <main>'
from extconf.rb:109:in `tap'
from extconf.rb:109:in `<main>'
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.0.0-p247/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out