The steps for installing Ruby on a Linux machine are listed below.
Note: before installing, make sure you have root permissions. Download the latest version of the Ruby zip file. Please click here to download . After downloading Ruby, extract it to the newly created directory: Now, configure and compile the source code, as follows: After installation, ensure that everything works properly by entering the following command on the command line: If everything works fine, the installed version of the Ruby interpreter willbe output, as shown above. If you have another version installed, differentversions are displayed. If your computer is already connected to Internet, the easiest way to install Ruby is to use the If you are an Apple system, you can use the RVM can install and manage multiple Ruby versions in the system. At the sametime can manage different After the installation is complete, some installation information is listed,including one line to note: It means that if you want to start using it, you need to execute a Check to see if it is installed correctly List known ruby versions: You can choose an existing version of rvm to install (take the installation of rvm version 2.4.2 as an example) Also continue to wait for the long download and compilation process, and when it is complete, Ruby and Ruby Gems will be installed. Query the installed ruby Uninstall an installed version Set Ruby version After RVM is installed, you need to execute the following command to set thespecified version of Ruby as the system default version Similarly, you can use other version numbers, as long as you are useful At this time, you can test whether it is correct or not. This may be because the default source of Ruby uses cocoapods.org, and it issometimes difficult to access this URL in China. One solution on the Internet is to replace the remote source with ruby-china, as follows: To verify that the replacement was successful, execute: Normal output: Please make sure that only gems.ruby-china.com If you use Gemfile and Bundle (for example, Rails project) You can use Bundler’s Gem source code mirror command. So you don’t have to change your Gemfile source. 6.4.1. Source code installation #
$ tar -xvzf ruby-2.2.3.tgz
$ cd ruby-2.2.3
$ ./configure
$ make
$ sudo make install
$ruby -v
ruby 2.2.3……
6.4.2. Automatically install Ruby #
yum
or
apt-get
. Enter the following command at the command prompt to install Ruby on your computer.$ sudo yum install ruby # CentOS, Fedora, or RHEL system
or
sudo apt-get install ruby-full # Debian 或 Ubuntu 系统
brew
command installation:$ brew install ruby
6.4.3. Install Ruby using RVM #
gem
set. Support for OS X, Linux, and other UNIX-like operating systems.Install RVM #
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys
409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
$ curl -sSL https://get.rvm.io | bash -s stable
...
To start using RVM you need to run `source /etc/profile.d/rvm.sh`
....
source
command to re-execute the newly modified initialization file, according to the installation prompt, execute the following command to load the RVM environment (the new Termal does not have to do this, it will reloadautomatically)source /etc/profile.d/rvm.sh
$ rvm -v
rvm 1.22.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
6.4.4. Install the Ruby environment with RVM #
$ rvm list known
$ rvm install 2.4.2
6.4.5. Rvm common commands #
$ rvm list
$ rvm remove 1.9.2
$ rvm 2.0.0 --default
rvm
install
installed that version.$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin13.0.0]
$ gem -v
2.1.6
$ gem source -r https://rubygems.org/
$ gem source -a https://gems.ruby-china.com/
$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com/
$ gem install rails
$ bundle config mirror.https://rubygems.org https://gems.ruby-china.com
source 'https://rubygems.org/'
gem 'rails', '4.1.0'
...