Install Ruby, Ruby Gems, and Rails on CentOS 7

To install Ruby, we will use Yum way in the Terminal:
Create a Virtual machine using Virtual Box or VMware workstation. Install CentOS 7. 
Start the virtual machine and open terminal.
sudo yum install ruby
Install Ruby, Ruby Gems, and Rails on CentOS 7

Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
* base: mirror.nbrc.ac.in
* extras: mirror.nbrc.ac.in
* rpmforge: mirror.nl.leaseweb.net
* updates: centosh5.centos.org
base                                                     | 3.7 kB     00:00
http://192.168.19.130/centos/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host"
Trying other mirror.
extras                                                   | 3.4 kB     00:00
extras/primary_db                                        |  30 kB     00:00
.
.
.
--> Finished Dependency ResolutionDependencies
Resolved
Transaction Summary
Install       3 Package(s)
Total download size: 2.3 M
Installed size: 7.8 M
Is this ok [y/N]: y
Downloading Packages:
.
.
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
.
ruby.x86_64 0:1.8.7.374-3.el6_6
Dependency Installed:
compat-readline5.x86_64 0:5.2-17.1.el6                     ruby-libs.x86_64 0:1.8.7.374-3.el6_6
Complete!
Now we have installed ruby successfully. Now let's install dependencies for Ruby.
Install Ruby dependencies
Open terminal and install different packages for gcc, openssl, httpd etc.
sudo yum install gcc g++ make automake autoconf curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel
--> Finished Dependency Resolution
Dependencies Resolved
Installing:
.
.
Installing for dependencies:
.
.
Updating for dependencies:.
.
.
Transaction Summary
Install      20 Package(s)
Upgrade      27 Package(s)
Total download size: 33 M
.
.
.
Complete!
At this point we have also installed dependencies for Ruby successfully. Let's install Ruby Gems
To Install Ruby Gems
sudo yum install ruby-rdoc ruby-devel
Resolving Dependencies
--> Running transaction check
.
.
.
Dependencies Resolved
Install       3 Package(s)
Total download size: 1.0 M
Installed size: 3.4 M
Is this ok [y/N]: y
.
.
.
Complete!
Install Ruby Gems
sudo yum install rubygems
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rubygems.noarch 0:1.3.7-5.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
.
.
.
Complete!
Install Rails
sudo gem update
Updating installed gems
Nothing to update
sudo gem update --system
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-2.4.5
.
.
To Install rails, open terminal in CentOS 7 and run
sudo gem install rails
You may face following Error:
ERROR:  Error installing rails: i18n requires Ruby version >= 1.9.3.
To Solve it, Click Here
sudo gem install rails
If you face same error ERROR:  Error installing rails: i18n requires Ruby version >= 1.9.3.
Then Click Here.
sudo gem install rails
If still same error persists then remove sudo from the command
gem install rails

Done!

Labels: , ,