在Linux上安装Ruby, RubyGems和ROR

在Linux上安装Ruby, RubyGems和ROR

php?name=Install" onclick="tagshow(event)" class="t_tag">Install php?name=Ruby" onclick="tagshow(event)" class="t_tag">Ruby with apt-get

1. Make sure the universe repository in /etc/apt/sources.list is uncommented:

deb http://us.archive.ubuntu.com/ubuntu/ edgy universe
deb-src http://us.archive.ubuntu.com/ubuntu/ edgy universe

  Also uncomment the security lines

deb http://security.ubuntu.com/ubuntu edgy-security universe
deb-src http://security.ubuntu.com/ubuntu edgy-security universe

2. Make sure you are up to date:

sudo apt-get update
sudo apt-get dist-upgrade

3. Install the ruby and mysql base packages:

sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby

4. We need to grab the latest ruby gems from rubyforge. You may need to modify this command if a version after 0.9.2 is available.

sudo wget http://rubyforge.org/frs/download.php/17190/rubygems-*.*.*.tgz
tar -xvzf rubygems-*.*.*.tgz
cd rubygems-*.*.*.tgz
sudo ruby setup.rb

5. Now let's install Ruby on Rails!

sudo gem install rails --include-dependencies

[edit] Install Ruby and Rails from source

1. Download source code of Ruby, RubyGems

wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p22.tar.bz2
wget http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz
tar -zxvf ruby-1.8.7-p22.tar.bz2 --directory=~/dev.dir/ruby/
tar -zxvf rubygems-1.1.1.tgz --directory=~/dev.dir/ruby/

2. Install Ruby

cd ~/dev.dir/ruby/ruby-1.8.7-p22
./configure
make
make test
sudo make install

To verify that you have a current version of Ruby, run the command ruby --version

3. Install RubyGems

cd ~/dev.dir/ruby/rubygems-1.1.1
sudo ruby setup.rb config
sudo ruby setup.rb setup
sudo ruby setup.rb install

4. Install Rails.

sudo gem install rails --include-dependencies

5. Issues you may ran into... If you get some output like:

[...] /usr/local/lib/ruby/site_ruby/1.8/rubygems/remote_fetcher.rb:4:in `require’: no such file to load — zlib (LoadError) [...]

The fix:

To be on the safe side be certain that zlib is installed:

$ sudo apt-get install zlib zlib-devel

$ cd ~/dev.dir/ruby/ruby-1.8.7-p22/ext/zlib/
$ ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
$ make
$ make install

Then re-install RubyGems, the issue may solved.
这篇已经很古老了
看来还是ubuntu 6.10时代的
非也,我自己写的。才在Ubuntu上做的。
非也,我自己写的。才在Ubuntu上做的。
谢谢!我编译ruby1.8.7也遇到了一些问题,这篇东西确实帮了我大忙,在google上很难找啊,最后还是在我们这里找到了,太棒了,大家加油啊!
补充:ruby1.8.6有安全问题,ruby网站上有说明,而ubuntu安装的还是有问题的版本,所以要自己编译才行。