How to Install Ruby on Rails CentOS 8. There is plenty of scripting languages and web frameworks that aid web development process. In this post we will understand what RoR is with the tool features and move onto installation part with CentOS 8.
What is Ruby on Rails
Ruby on Rails is an open source framework used for developing server side web applications. It is relatively popular among startups since it helps in developing prototypes and Minimum Viable Products (MVPs) rapidly. It enables the developers to use its ready made solutions and helps to save programming time.
Rails server act as Ruby’s top layer and enables web developers to build unique web applications. The framework operates in a Model View Controller (MVC) environment, which has one of the best design principles. It can separate business logic from the databases, queries, and UI UX code effortlessly.
After its introduction in 2005, the entire web developing world was introduced to its new and unique features. Its Convention Over Configuration (CoC) ideology helps in creating web applications in a completely eccentric way.
By default, the latest version of Node.js server is not included in the CentOS default repo. So you will need to add the Node Source repo to your server.
Run the following command to add the Node Source repo:
Rbenv is a lightweight tool that provides an easy way to install and manage the versions of Ruby. Run the following command to install rbenv into your home directory and set appropriate environment variables.
Next, verify the Rbenv installation using the following command:
rbenv -v
You will get the following output:
rbenv 1.2.0-14-gc6cc0a1
To list all available Ruby versions, run the following command:
rbenv install -l
You will get a list of all Ruby versions in the following output:
2.6.10
2.7.6
3.0.4
3.1.2
jruby-9.3.4.0
mruby-3.0.0
rbx-5.0
truffleruby-22.1.0
truffleruby+graalvm-22.1.0
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.
To install the latest Ruby version, run the following command:
rbenv install 3.1.2
To set the Ruby as the default version for all shells, run the following command:
rbenv global 3.1.2
You can also verify the Ruby version using the following command:
ruby -v
To install the bundler, run the following command:
RVM is a Ruby Version Manager used to install and manage ruby versions independently by automatically downloading its dependencies.
First, install the RVM with the following command:
curl -sSL https://get.rvm.io | bash
You will get the following output:
Downloading https://github.com/rvm/rvm/archive/master.tar.gz
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete:
* First you need to add all users that will be using rvm to 'rvm' group,
and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.
* To start using RVM you need to run `source /etc/profile.d/rvm.sh`
in all your open shell windows, in rare cases you need to reopen all shell windows.
* Please do NOT forget to add your users to the rvm group.
The installer no longer auto-adds root or users to the rvm group. Admins must do this.
Also, please note that group memberships are ONLY evaluated at login time.
This means that users must log out then back in before group membership takes effect!
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
👉 Donate: https://opencollective.com/rvm/donate
Activate the RVM environment variable using the following command:
source /etc/profile.d/rvm.sh
Verify the RVM version using the following command:
rvm -v
You will get the following output:
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
To install the latest Ruby version, run the following command:
rvm install 3.1.2
You should get the following output:
Installed rubygems 3.3.7 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-3.1.2 - #gemset created /usr/local/rvm/gems/ruby-3.1.2@global
ruby-3.1.2 - #importing gemset /usr/local/rvm/gemsets/global.gems................................................................
ruby-3.1.2 - #generating global wrappers........
ruby-3.1.2 - #gemset created /usr/local/rvm/gems/ruby-3.1.2
ruby-3.1.2 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-3.1.2 - #generating default wrappers........
ruby-3.1.2 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-3.1.2 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
Now, set the Ruby version 3.1.2 as the default version using the following command:
rvm use 3.1.2 --default
To verify the Ruby version, run the following command:
ruby -v
You will get the Ruby version in the following output:
Next, create a database using the following command:
rake db:create
Then start the server using the following command:
rails server -b 0.0.0.0
Once the server is started, you will get the following output:
=> Booting Puma
=> Rails 7.0.2.4 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.4 (ruby 3.1.2-p20) ("Birdie's Version")
* Min threads: 5
* Max threads: 5
* Environment: development
* PID: 43515
* Listening on http://0.0.0.0:3000
Use Ctrl-C to stop
Now, open your web browser and access your Rails application using the URL http://your-server-ip:3000. You should see your Rails app in the following screen:
There is a variety of programming languages, frameworks and development platforms to compare. RoR is the top contender as it is multi capable and versatile.
In this post, we explained how to install Ruby on Rails using different ways. We also create a test application with MySQL database using Ruby on Rails. I hope this will help you to use Ruby on Rails in the development environment.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
00votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.