Page tree
Skip to end of metadata
Go to start of metadata

Overview

This document describes how to install a Sinatra web application. You can use Sinatra to quickly create web applications on the Ruby platform which you can register in cPanel's Application Manager interface (cPanel >> Home >> Software >> Application Manager).

Warnings:

  • cPanel Technical Support does not provide assistance with the steps in this document.
  • We recommend that only experienced system administrators perform these steps.
  • We are not responsible for any data loss.

Notes:

  • We recommend that you perform the steps in this document via the command line as a cPanel user unless otherwise specified.
  • You can also use cPanel's Terminal interface (cPanel >> Home >> Advanced >> Terminal) to perform these steps in cPanel & WHM version 72 and later.
  • In this document, user represents the cPanel user, and frank represents the application's name.


For more information, read Sinatra's documentation.

Install Sinatra


Pre-installation settings.

Before you begin, make certain that the following EasyApache 4 RPMs exist on your server:

  • ea-ruby24-mod_passenger

    Note:

    If you enable this module, the system will disable Apache's mod_userdir module.

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

    Note:

    The ea-apache24-mod_env module allows you to add environment variables when you register your application. For more information about environment variables, read our Application Manager documentation.


If you need to install these RPMs, run the following command as the root user:

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




Install the sinatra gem.

To install the sinatra Ruby gem, run the following command:

scl enable ea-ruby24 'gem install sinatra'

If you do not wish to use the scl utility, perform the following steps to install the sinatra Ruby gem:

  1. Log in to the server as a cPanel user.

  2. Add the following line to your shell's rc file (for example, /home/user/.bashrc file):

    source /opt/cpanel/ea-ruby24/enable
  3. Log out of your terminal session, and log back in again.

    Note:

    You can also create an additional terminal session.

  4. Run the gem install sinatra command

 


 

Create the application's directory path.

After you install the sinatra Ruby gem, create the application's directory path, relative to your home directory, for example:

/home/user/frank

 


 

Create the application's ruby files.

After you create the application's directory path, add the ruby application file. To do this, perform the following steps:

  1. Change to the application's directory
  2. Create the app.rb file with a text editor.
  3. Add the process that you want the application to execute, for example:

    require 'sinatra/base'
    
    class Fools < Sinatra::Base
      get '/' do
        'Fools Rush In'
      end
    end

    Note:

    For more information about how to add processes to the app.pp file, read Sinatra's documentation.

  4. Create the config.rb file with a text editor.
  5. Add the following content to the file:

    require File.absolute_path("app.rb")
    
    run Fools

 


 

Register the application.

After you set the file permissions, register the application. To do this, use UAPI's PassengerApps::register_application function, or cPanel's Application Manager interface (cPanel >> Home >> Software >> Application Manager).

 


 

Restart apache.

Important:

This step is optional. UAPI's PassengerApps::register_application function performs an Apache restart, but may not execute immediately.

After you create the application's Apache configuration, restart Apache. To do this, run the following command as the root user:

/usr/local/cpanel/scripts/restartsrv_httpd

After Apache restarts, you can access the application in cPanel's Application Manager interface (cPanel >> Home >> Software >> Application Manager).

 Additional documentation