Tutorial on installing the Ruby interpreter on the operating system.
Ruby installation-Linux
The steps for installing Ruby on a Linux machine are listed below.
Note: before installation, make sure that you have the root permission.
Source code Installation
Download the latest Ruby compressed file. Click here to download.
After downloading Ruby, decompress it to the newly created directory:
$ tar -xvzf ruby-2.2.3.tgz $ cd ruby-2.2.3
Now, configure and compile the source code as follows:
$ ./configure$ make$ sudo make install
After installation, enter the following command in the command line to ensure that everything works properly:
$ruby -vruby 2.2.3……
If everything works properly, the version of the installed Ruby interpreter will be output, as shown above. If you have installed other versions, different versions are displayed.
Automatically install Ruby
If your computer has been connected to the Internet, the simplest way to install Ruby is to use yum or apt-get. Enter the following command in 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 or Ubuntu System
If you are an Apple system, you can use the brew command to install it:
$ brew install ruby
Ruby installation-Windows
The steps for installing Ruby on a Windows machine are listed below.
Note: You may have different available versions during installation.
- In the Windows system, we can use RubyInstaller to install the Ruby environment. For details, click here to download.
- After downloading rubyinstaller, decompress it to the newly created directory:
- Double-click the rubyinstaller-2.2.3.exe file to start the Ruby Installation Wizard.
- Click Next to continue the Wizard. Remember to check Add Ruby executables to your PATH until the Ruby installer completes Ruby installation.
If your installation does not properly configure the environment variables, you may need to configure the environment variables.
- If you are using Windows 9x, go to your c: \ autoexec. add: set PATH = "D: \ (ruby installation directory) \ bin; % PATH %" to bat"
- For Windows NT/2000, you need to modify the registry.
- Click Control Panel | System Performance | environment variable.
- Under system variables, select Path and click EDIT.
- Add the Ruby directory at the end of the variable value list and click OK.
- Under system variables, select PATHEXT and click EDIT.
- Add. RB and. RBW to the variable value list, and click OK.
After installation, enter the following command in the command line to ensure that everything works properly:
$ruby -vruby 2.2.3
If everything works properly, the version of the installed Ruby interpreter will be output, as shown above. If you have installed other versions, different versions are displayed.