Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
stylenone

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).

Warning
titleWarnings:
  • 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.


Note
titleNotes:
  • 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


Section


Column
width72px


Column

Pre-installation settings.

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

  • ea-ruby24-mod_passenger

    Note
    titleNote:

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


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

    Note
    titleNote:

    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:

Code Block
languagebash
yum install ea-ruby24-mod_passenger ea-ruby24-ruby-devel ea-apache24-mod_env






Section


Column
width72px


Column

Install the sinatra gem.

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

Code Block
languagetext
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):

    Code Block
    languagebash
    source /opt/cpanel/ea-ruby24/enable


  3. Log out of your terminal session, and log back in again.

    Note
    titleNote:

    You can also create an additional terminal session.


  4. Run the gem install sinatra command


 


 

Section


Column
width72px


Column

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:

Code Block
/home/user/frank



 


 

Section


Column
width72px


Column

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:

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


    Note
    titleNote:

    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:

    Code Block
    languagetext
    require File.absolute_path("app.rb")
    
    run Fools


 

 


 

Section


Column
width72px


Column

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).


 


 

Section


Column
width72px


Column

Restart apache.

Warning
titleImportant:

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:

Code Block
languagetext
/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

Localtab Group


Localtab
activetrue
titleSuggested documentation

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("ruby","apache") and label = "whm" and space = currentSpace()


Localtab
titleFor cPanel users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("ruby","apache") and label = "cpanel" and space in (currentSpace(),"76Docs")


Localtab
titleFor WHM users

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("ruby","apache") and label = "whm" and space = currentSpace()


Localtab
titleFor developers

Content by Label
showLabelsfalse
max5
showSpacefalse
cqllabel in ("ruby","apache") and space = "DD"