Many times we will find that the real production environment is not a lot of external network, only intranet environment, this time we need to install RubyGems, we can not provide the Yum command to install online, this time we need to download the installation package for offline installation. This article is a brief introduction if you install RubyGems offline
Before installing we briefly introduce the next RubyGems
I. Introduction of RubyGems
RubyGems is a package manager for Ruby that provides a standard format for distributing Ruby programs and libraries, as well as a tool for managing package installation.
The RubyGems is designed to conveniently manage gem-installed tools, as well as servers for distributing gems. This is similar to the apt-get under Ubuntu, the Yum,python pip of Centos.
RubyGems was created around November 2003 and became part of the Ruby Standard library since Ruby version 1.9.
Second, online installation RubyGems
Direct installation by command
& Yum Install RubyGems
Second, offline installation RubyGems
If your Ruby is below version 1.9, you can also install it manually:
- First download the installation package: Https://rubygems.org/pages/download.
- Unzip and go to directory, execute command:Ruby setup.rb
Decompression TAR-ZXVF rubygems-2.6.12.tgz
$ cd/home/cmfchina/rubygems
$ TAR-ZXVF rubygems-2.6. tgz.
Execute command:Ruby setup.rb
Update RubyGems command:
1 $ gem update--system # requires administrator or root user
Third, RUBYGEMS environment variable configuration (requires root permission)
Command:
$ which gem
If you do not find, you need to set the environment variables, there is no need to set up, after the content will not go to see, la La ~ ~ ~ ~.
Method One,
Directly under the current root directory, it is the installation directory of Ruby. Enter the command VI BASHRC, and then add the following statement at the end:export path=/home/cmfchina/rubygems/rubygems-2.6.12/bin: $PATH, Set the path path, place the installed RUBYGEMSL path in front of the system path, and avoid invoking the operating system's own RubyGems
:
Save to exit (press ESC, then enter: Wq Save to exit)
Method Two, (the second is recommended, because the first type of BASHRC is a system-level environment variable)
Enter the command vim/etc/profile to add the bin directory path to the installation RubyGems in the file path. Then save the Execute command:source/etc/profile
$ vi/etc/profile
:
On the last side of the file, path adds the bin path to the RubyGems,
Save to exit (press ESC, and then enter: Wq save exit), where you set the path path, put the installed RubyGems in front of the system path, avoid calling the operating system's own RubyGems
Finally, you need to execute the command:source/etc/profile to take effect immediately
$ source/etc/profile
Special Note:
You will normally need to unregister the system to take effect, and finally you can test it with the echo command:
See if the output is already/home/cmfchina/rubygems/rubygems-2.6.12/bin this path.
At this point, Ruby installation is complete!
Linux Offline Installation RubyGems detailed