转载:http://www.hackido.com/2009/04/install-ruby-rails-on-ubuntu-904-jaunty.html
1 Update system to the latest version
sudo apt-get update
sudo apt-get dist-upgrade
2 We'll be installing some software that needs to be built so we'll need to get packages required for compiling.
sudo apt-get install build-essential
3 Once you've got the tools, it's time to install MySQL and Ruby. If you're using SQLite you may not need all this stuff. Otherwise, just copy and paste this command into your terminal if you're in a hurry.
sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.0 mysql-common mysql-server-5.0 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 libhtml-template-perl mysql-server-core-5.0
4: Grab the latest ruby gems and install them. As always be sure to check rubyforge.org to make sure you're grabbing the latest one. As of this writing it's 1.3.4 but it never hurts to confirm.
wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.4.tgz
tar xvzf rubygems-1.3.4.tgz
cd rubygems-1.3.4
sudo ruby setup.rb
5 On the command line, type gem -v. if you get this message we need to make some symlinks:
The program 'gem' can be found in the following packages:
* rubygems1.8
* rubygems1.9
Try: sudo apt-get install
-bash: gem: command not found
Let's create those symlinks now
sudo ln -s /usr/bin/gem1.8 /usr/local/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
sudo ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
sudo ln -s /usr/bin/ri1.8 /usr/local/bin/ri
sudo ln -s /usr/bin/irb1.8 /usr/local/bin/irb
6 Install Ruby on Rails! You can leave off the --no-rdoc and --no-ri switches if you're on a machine with plenty of ram. But just in case you've got a more modest setup (say 256MB or less) I'd just use the following:
sudo gem install rails --no-rdoc --no-ri
3、安装卸载指定版本rails
gem install rails -v 版本号
gem uninstall -v 版本号
如果想清除所有已安装的老版本gem,直接运行
gem cleanup
即可