First of all, 2012 years, already have Ruby 1.9.3, why I want to install 1.9.2.
Answer: Because I'm learning Ruby on Rails, the reference book Ruby on RAISL 3 tutorial is written according to 1.9.2, and Heroku server seems to support only Ruby 1.9.2
Start Ubuntu and install some related libraries with the following command
$ sudo apt-get install gcc g++ build-essential libssl-dev libreadline-gplv2-dev zlib1g-dev linux-headers-generic
Download the latest (or appropriate) Ruby 1.9.2 source
View: ftp://ftp.ruby-lang.org/pub/ruby/1.9/
or view: http://ftp.ruby-lang.org/pub/ruby/1.9/
$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
Compile and install Ruby
$ TAR-ZXF ruby-1.9.2-p290.tar.gz
$ CD ruby-1.9.2-p290
$./configure--prefix=/usr/local/ruby
$ make && sudo make install
Environment settings
$ sudo vi/etc/environment
Add Ruby's path to the environment variable and save the/etc/environment, as follows:
Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/ruby/bin"
After you have modified the environment variable file, you need to make the change come into effect with the source command as follows:
$ source/etc/environment
To verify that the installation was successful, you can enter the following command to test:
$ruby –v
After confirming the success of the installation, you can add the command link by command, and I am not sure what the purpose of creating these links is, according to the principle of ruby "convention greater than configuration", it should be a convention. (Keyboardota)
$ sudo ln-s/usr/local/ruby/bin/ruby/usr/local/bin/ruby
$ sudo ln-s/usr/local/ruby/bin/gem/usr/bin/gem
You can now experience ruby in 20 minutes.
Reference: Install Ruby on Rails on Ubuntu