How to Create a Sinatra Ruby Application

Sinatra is an open-source web application library, written in Ruby and is a domain-specific language. It depends on the Rack webserver interface.


Pre-installation settings :

Certain  EasyApache 4 RPM’S need to exist on the server-

  • ea-ruby24-ruby-devel
  • ea-apache24-mod_env

The following command needs to be run to install these-

yum install ea-ruby24-mod_passenger ea-ruby24-ruby-devel ea-apache24-mod_env

Installation of the Sinatra Gem ( Steps )

  1. Log in to the server as a CPANEL user.
  2. The following line needs to be added to the RC file


source /opt/cpanel/ea-ruby24/enable

  1. Log out from a terminal session and log in again.
  2. Then the Sinatra Gem can be run.


Creating a directory path for the application

After the installation,  a directory path has to be created. Example-


Creation of the application’s Ruby files :

  • Change the application’s directory.
  • Create the RB file with a text editor’s help.
  • One needs to add the code for the execution of the application.

require ‘Sinatra/base’

class Example

get ‘/’ do




Registration of the application :

After the setting file permissions, register the application. The usage of CPANEL’S Application Manager is required.

(cPanel >> Home >> Software >> Application Manager)

Restarting Apache :

To restart Apache, run the following command-


The application is accessible after Apache restarts in Cpanel’s Application manager interface –

(cPanel >> Home >> Software >> Application Manager).

RVM is an unix-like software, used to manage more than one installations of Ruby on a single device.

gpg –keyserver hkp:// –recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3$ curl -sSL | bash -s stable –ruby

There are a few choices of code writing tools :

  • Atom, which runs on Electron to build cross platform apps.
  • Sublime Text, is renowned for being an easy usage text editor.
  • RubyMine, might take some time to set up but comes with pre-installed tools.
  • Vim, too is a popular text editor, meant for advanced users.


Bundler is used to manage dependencies and pulling Sinatra into the development environment is done by bundle install..

bundle install

Using builder 3.2.2

Using jwt 1.5.6

Using multi_json 1.12.1

Using rack 1.6.5

Using tilt 2.0.5

Using bundler 1.13.3

Using twilio-ruby 4.13.0

Using rack-protection 1.5.3

Using sinatra 1.4.7


The post How to Create a Sinatra Ruby Application appeared first on BuycPanel.

Go to Source
Author: Allura