首页 > linux > Installing Ruby on Rails on CentOS/Redhat 4.x

Installing Ruby on Rails on CentOS/Redhat 4.x

2008年2月6日

This doesn’t seem to be terribly well documented, so I thought I’d post it here for those googling for a solution.

Problem

Installing Ruby on Rails on CentOS (or Redhat), the RubyGems part of the official installation instructions (or the instructions listed in this excellent SitePoint book which I’m working through at the moment) may yield this result:

# cd /usr/local/src/rubygems-0.9.2
# ruby setup.rb

< --- lib
/usr/local/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:4:in `require': no such file to load — zlib (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:4
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:8:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:8
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:501:in `require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:501
from /usr/local/src/rubygems-0.9.2/./post-install.rb:81:in `require’
from /usr/local/src/rubygems-0.9.2/./post-install.rb:81:in `install_sources’
from /usr/local/src/rubygems-0.9.2/./post-install.rb:116:in `try_run_hook’
from setup.rb:584:in `run_hook’
from setup.rb:1322:in `exec_task_traverse’
from setup.rb:1175:in `exec_install’
from setup.rb:894:in `exec_install’
from setup.rb:712:in `invoke’
from setup.rb:681:in `invoke’
from setup.rb:1359

Solution

A zlib error? Hrm. Double check zlib and zlib-devel are installed (I’m not sure if zlib-devel is needed but I installed it for good measure).

# yum install zlib zlib-devel

Then:

# cd /usr/local/src/ruby-1.8.5-p2/ext/zlib/
# ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
# make
# make install

Next, install RubyGems. Note that running “ruby setup.rb” on it’s own doesn’t seem to work, try this:

# cd /usr/local/src/rubygems-0.9.2/
# ruby setup.rb config
# ruby setup.rb setup
# ruby setup.rb install

All’s good in the hood. Now continue with the rest of the installation.

# gem install rails --include-dependencies

Enjoy.

 link from :http://lucaschan.com/weblog/2007/03/22/installing-ruby-on-rails-on-centosredhat-4x/

linux

  1. 目前还没有任何评论.
  1. 目前还没有任何 trackbacks 和 pingbacks.