news
Serverspace has added a new Rocky Linux OS
BM
September 22, 2022
Updated June 7, 2023

Installing Ruby on Rails 3.1.2 on Ubuntu 20.04 server

Linux Ubuntu VPS

Using another OS?

Select the desired version or distribution.

A short note about the framework:

Ruby on Rails was written in the programming language "Ruby". It was created as far back as 2004, and gained its popularity through an interaction with Apple in 2006. At that time "Apple" announced that it will ship "Ruby on Rails" together with Mac OS X 10.5 "Leopard" operating system.

Also we must not forget that this framework has influenced the development of web applications through innovative features such as creation of database tables, migration and creation of presentation frameworks to ensure fast application development.

The uniqueness of Ruby

There are many web development frameworks in the programming world, but Django and Ruby on Rails stand out the most.

This makes them the most popular web development frameworks and this popularity will continue to grow.

Scalability

While Django inherited its scalability from Python, it is still slightly behind Rails. It has better scalability, which is a result of its qualities of freedom and code flexibility. Both are heavyweight web development frameworks, so they are both designed with scalability in mind, but in this case the win goes to Ruby on Rails.

Syntax

Ruby's syntax is known to be very flexible. However, this can not always be attributed to the advantages of Ruby on Rails. It can cause problems and make it difficult to pass a project to other team members, as the same function can be implemented in different ways, creating confusion.

Whereas Python advocates that there should only be one obvious way to do something, which makes the code easier to debug and read.

Update the packages on the system:

apt-get update && apt-get upgrade

ruby-1

ruby-2

Install packages:

apt install curl # Install the curl program

ruby-3

apt install git # Install the git program

ruby-4

apt-get install -y nodejs # Install the nodejs program.

ruby-5

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - # Install the yarn program

ruby-6

Now it remains to install the remaining packages to make it work:

sudo apt-get install zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn -y

ruby-7

Installation through Rbenv:

Next, the Ruby installation will be handled by the Rbenv manager. This will speed up the installation process. First install rbenv , then ruby-build.

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

ruby-8

ruby-9

Install ruby-build:

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

ruby-10

echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

ruby-11

 

Install the Ruby programming language using the commands below:

rbenv install 3.1.2
rbenv global 3.1.2

ruby-12

A bit about Rbenv:

This is a command line tool used to install Ruby on Rails, it also provides a good environment for developing applications using Ruby on Rails.

gem install bundler # Last step, install bundler.

ruby-13

gem install rails -v 7.0.2.4 # Install Rails software

ruby-14

rbenv rehash # Make available the executable with the command below

ruby-15

Databases for Rails:

By standard, sqlite3 is installed, but it is better to use another database, for example PostgreSQL or MySQL. In our case, we will use PosgreSQL. (But it also takes into account how to enable MySQL).

A little bit about sqlite3:

This database was developed in the spring of 2000. The purpose of developing SQLite - was to be able to work with the program without installing a database management system or the need to involve the database administrator.

SQLite is one of the four formats recommended for long-term storage of data sets approved for use by the Library of Congress.

A little about PostgreSQL:

It is a free, open-source relational database management system. It began back in 1982, evolving from the Ingres project which was developed at the University of California, Berkeley.

PostgreSQL gained popularity due to its query optimizations. It combines many indexes for different purposes and makes query execution much simpler and more efficient because it prescribes which steps to perform and in what time frame.

sudo apt install postgresql-11 libpq-dev # Now install PostgreSQL

ruby-16

rails new myapp -d postgresql # Include PostgreSQL in Rails

ruby-17

sudo apt-get install mysql-server mysql-client libmysqlclient-dev -y # Install MySQL

 

A little about MySQL:

It is free and open source software under the GNU General Public License and is also available under various proprietary licenses. MySQL has standalone clients which allow users to directly access and interact with the database, but more often MySQL is used with other programs to implement applications that require relational database capabilities.

rails new myapp -d mysql # Enable MySQL on Rails

ruby-18

cd myapp # Go to the myapp directory.

ruby-19

rake db:create # Create a new database there.

ruby-20

To change the ip address of the server, type the command below:

rails s -b y.y.y.y (y.y.y.y is our server ip address)
rails s -b 45.138.24.121

ruby-21

We can go to our server using ip-server:3000

ruby-22

Conclusion:
This publication makes it easy to install Ruby on Rails on your Ubuntu server.
The only question that remains is what framework to choose and why?

 

 

Vote:
5 out of 5
Аverage rating : 5
Rated by: 5
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.