You should have the necessary required packages:
Ruby
sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8
sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby
nokogiri
sudo apt-get install libxslt-dev libxml2-dev zlib1g-dev
sudo gem install nokogiri
This should fix this. Or alternatively see Problems installing Nokogiri (1.5.2) on Ubuntu 12.10 Which should also be able to answer your question. Pointer for future reference. Try to research on stackoverflow or other resources that may have the answer because you may find that your problem has already been solved
Wi