Create a Ruby on Rails Application Using cPanel
Author: admin admin Reference Number: AA-00429 Views: 32468 Created: 2016-06-23 06:46 Last Updated: 2025-08-14 10:11 0 Rating/ Voters

How to Run Ruby Applications Using CloudLinux Setup Ruby App Tool

Overview

This guide will walk you through creating and deploying Ruby applications on your premium hosting account using the CloudLinux "Setup Ruby App" tool. This feature simplifies Ruby application deployment by handling server configuration automatically, making it accessible for beginners who want to run Ruby applications without complex setup.

What is the CloudLinux Setup Ruby App Tool?

The CloudLinux Setup Ruby App tool is an automated system that manages Ruby application deployment and configuration. It provides an easy-to-use interface for setting up Ruby environments, managing dependencies, and deploying applications without requiring advanced server administration knowledge.

Benefits of Using Setup Ruby App

  • Simplified Deployment: No manual server configuration required
  • Multiple Ruby Versions: Choose from various Ruby versions
  • Gem Management: Built-in support for installing Ruby gems
  • Isolated Applications: Each app runs in its own secure environment
  • Rack Compatible: Works with popular frameworks like Rails, Sinatra, and others
  • Automatic Dependency Management: Handles Bundler and gem dependencies

Prerequisites

  • Premium hosting account with CloudLinux support
  • Basic understanding of Ruby programming
  • Ruby application or script ready to deploy
  • Access to cPanel

Accessing Your Hosting Control Panel

Method 1: Client Portal Access

  1. Visit the client portal: https://ifastnet.com/portal/clientarea.php
  2. Log in with your hosting account credentials
  3. Navigate to your hosting services
  4. Click on the cPanel access button for direct access

Method 2: Direct cPanel Access

  • Visit: https://yourdomain.com/cpanel (replace "yourdomain.com" with your actual domain)
  • Enter your cPanel username and password

Step-by-Step Guide to Setup Ruby Application

Step 1: Access the Ruby App Tool

  1. Log into your cPanel using one of the methods above
  2. Scroll down to the "Software" section
  3. Look for and click on "Setup Ruby App" or "Ruby App"
  4. You'll be taken to the Ruby application management interface

Step 2: Create a New Ruby Application

  1. Click the "Create Application" button
  2. Fill in the application configuration form:

Required Configuration Settings:

  • Ruby Version: Select your preferred Ruby version (e.g., 2.7, 3.0, 3.1, 3.2)
  • Application Mode: Choose between "Development" or "Production"
  • Application Root: Directory where your Ruby files will be stored
  • Application URL: URL path where your app will be accessible
  • Application Startup File: Main Ruby file (typically config.ru for Rack apps)

Example Configuration:

  • Ruby Version: 3.1
  • Application Mode: Production
  • Application Root: ruby_app (creates /public_html/ruby_app/)
  • Application URL: /myrubyapp (accessible at yoursite.com/myrubyapp)
  • Application Startup File: config.ru
  1. Click "Create" to initialize the Ruby application environment

Step 3: Understanding the Generated Structure

After creation, the system generates a basic directory structure:

public_html/ruby_app/
??? config.ru (Rack configuration file)
??? Gemfile (Gem dependencies)
??? Gemfile.lock (Locked gem versions)
??? tmp/ (Temporary files)
??? public/ (Static files)
??? app/ (Your application code)

Step 4: Upload Your Ruby Application Files

Using cPanel File Manager:

  1. Return to cPanel main page
  2. Click on "File Manager"
  3. Navigate to your Application Root directory (e.g., public_html/ruby_app/)
  4. Upload your Ruby application files:
    • Main application files (.rb files)
    • Gemfile (if you have specific gem requirements)
    • config.ru (Rack configuration)
    • Any additional directories (views, models, etc.)

Typical Ruby Application Structure:

ruby_app/
??? config.ru
??? Gemfile
??? app.rb (or main application file)
??? views/ (if using a framework like Sinatra)
??? public/ (static assets)
??? lib/ (additional Ruby modules)

Step 5: Configure Your Gemfile

Create or edit your Gemfile to specify required gems:

# Gemfile
source 'https://rubygems.org'

ruby '3.1.0'  # Specify Ruby version

gem 'rack'
gem 'sinatra'  # If using Sinatra framework
gem 'rails'    # If using Rails framework
gem 'pg'       # PostgreSQL adapter (if needed)
gem 'mysql2'   # MySQL adapter (if needed)

group :development do
  gem 'puma'
end

group :production do
  gem 'passenger'
end

Step 6: Create or Configure config.ru

The config.ru file is essential for Rack-based applications:

For a Simple Sinatra App:

# config.ru
require './app'
run Sinatra::Application

For a Rails Application:

# config.ru
require_relative 'config/environment'
run Rails.application

For a Custom Rack Application:

# config.ru
require './app'

class MyApp
  def call(env)
    [200, {'Content-Type' => 'text/html'}, ['<h1>Hello from Ruby!</h1>']]
  end
end

run MyApp.new

Step 7: Install Gems and Dependencies

  1. Return to the Setup Ruby App interface in cPanel
  2. Find your created application in the list
  3. Look for "Run Bundle Install" or "Install Dependencies" option
  4. Click to install all gems specified in your Gemfile

Alternative Method - Using Terminal:

  1. In cPanel, open "Terminal"
  2. Navigate to your application directory:
    cd ~/public_html/ruby_app
    
  3. Run bundle install:
    bundle install
    

Step 8: Start Your Ruby Application

  1. In the Setup Ruby App interface, locate your application
  2. Click the "Start" or "Restart" button
  3. The application status should change to "Running"
  4. Your Ruby application is now live and accessible

Step 9: Test Your Application

  1. Visit your application URL in a web browser
  2. For the example above: https://yoursite.com/myrubyapp
  3. Verify that your Ruby application is running correctly
  4. Check for any error messages or issues

Sample Ruby Applications

Basic Sinatra Application

app.rb:

require 'sinatra'

get '/' do
  '<h1>Welcome to My Ruby App!</h1><p>Running on Sinatra</p>'
end

get '/hello/:name' do
  "Hello #{params[:name]}!"
end

get '/time' do
  "Current time: #{Time.now}"
end

config.ru:

require './app'
run Sinatra::Application

Gemfile:

source 'https://rubygems.org'
gem 'sinatra'
gem 'rack'

Simple Rack Application

app.rb:

class HelloWorld
  def call(env)
    request_path = env['PATH_INFO']
    
    case request_path
    when '/'
      [200, {'Content-Type' => 'text/html'}, ['<h1>Hello Ruby World!</h1>']]
    when '/json'
      [200, {'Content-Type' => 'application/json'}, ['{"message": "Hello from Ruby"}']]
    else
      [404, {'Content-Type' => 'text/html'}, ['<h1>Page Not Found</h1>']]
    end
  end
end

config.ru:

require './app'
run HelloWorld.new

Managing Your Ruby Application

Application Status and Control

  • Start: Launches your Ruby application
  • Stop: Stops the application temporarily
  • Restart: Restarts the application (use after code changes)
  • Status: Shows current application state (Running/Stopped)

Viewing Application Logs

  1. In the Setup Ruby App interface, look for "Logs" or "Error Logs"
  2. Application logs help diagnose issues and monitor performance
  3. Error logs show Ruby exceptions and server errors

Updating Your Application

  1. Upload new or modified files via File Manager or FTP
  2. If you change gems, run "Bundle Install" again
  3. Always restart the application after making changes
  4. Test thoroughly after updates

Working with Popular Ruby Frameworks

Ruby on Rails Applications

  1. Upload your entire Rails application to the application root
  2. Ensure config.ru is present in the root directory
  3. Configure your database settings in config/database.yml
  4. Run bundle install to install all gem dependencies
  5. You may need to run migrations: bundle exec rake db:migrate

Sinatra Applications

  1. Much simpler setup than Rails
  2. Usually consists of a main app file and config.ru
  3. Minimal gem requirements
  4. Great for small web applications and APIs

Custom Rack Applications

  1. Most flexible option for Ruby web applications
  2. Direct control over request/response handling
  3. Minimal overhead and dependencies
  4. Perfect for APIs and microservices

Database Integration

MySQL Integration:

# In your Gemfile
gem 'mysql2'

# In your application
require 'mysql2'

client = Mysql2::Client.new(
  host: 'localhost',
  username: 'your_db_user',
  password: 'your_db_password',
  database: 'your_database'
)

results = client.query("SELECT * FROM users")

Using ActiveRecord (without Rails):

# Gemfile
gem 'activerecord'
gem 'mysql2'

# In your app
require 'active_record'

ActiveRecord::Base.establish_connection(
  adapter: 'mysql2',
  host: 'localhost',
  username: 'your_db_user',
  password: 'your_db_password',
  database: 'your_database'
)

class User < ActiveRecord::Base
end

Troubleshooting Common Issues

Application Won't Start

  • Check Ruby version compatibility: Ensure your app works with the selected Ruby version
  • Verify config.ru: Make sure the startup file exists and is configured correctly
  • Review gem dependencies: Ensure all required gems are installed
  • Check file permissions: Verify files have proper read permissions

Gem Installation Errors

  • Network issues: Retry gem installation
  • Version conflicts: Check for compatible gem versions
  • Missing dependencies: Install system dependencies if required
  • Gemfile syntax: Verify Gemfile syntax is correct

500 Internal Server Error

  • Check application logs: Look for Ruby exceptions in error logs
  • Syntax errors: Review your Ruby code for syntax issues
  • Missing files: Ensure all required files are uploaded
  • Database connections: Verify database credentials and connectivity

Performance Issues

  • Optimize Ruby code: Review code efficiency
  • Database queries: Optimize database interactions
  • Memory usage: Monitor application memory consumption
  • Caching: Implement appropriate caching strategies

Best Practices for Ruby Applications

Code Organization:

  • Follow Ruby naming conventions
  • Use proper directory structure
  • Separate concerns (models, views, controllers)
  • Include comprehensive error handling

Security Considerations:

  • Never commit sensitive data to version control
  • Use environment variables for secrets
  • Validate all user inputs
  • Keep gems updated to latest secure versions
  • Use HTTPS for production applications

Performance Optimization:

  • Use efficient algorithms and data structures
  • Implement proper caching strategies
  • Optimize database queries
  • Monitor application performance regularly

Development Workflow:

  • Test applications locally before deployment
  • Use version control (Git) for your code
  • Maintain staging and production environments
  • Document your application setup and dependencies

Environment Variables

Setting Environment Variables:

  1. In the Setup Ruby App interface, look for "Environment Variables"
  2. Add variables for database URLs, API keys, etc.
  3. Access them in your Ruby code:
database_url = ENV['DATABASE_URL']
api_key = ENV['API_KEY']

Configuration Management:

# config/database.yml (for Rails)
production:
  adapter: mysql2
  host: <%= ENV['DB_HOST'] || 'localhost' %>
  username: <%= ENV['DB_USERNAME'] %>
  password: <%= ENV['DB_PASSWORD'] %>
  database: <%= ENV['DB_NAME'] %>

Getting Support

If you encounter issues with your Ruby application or need assistance:

Support Portal Access:

  1. Visit: https://support.ifastnet.com/login.php
  2. First-time users: You'll need to register for a support account before creating tickets
  3. Create a detailed support ticket describing your issue

What to Include in Your Support Ticket:

  • Your domain name and application URL
  • Ruby version you're using
  • Framework (Rails, Sinatra, custom Rack)
  • Description of what you're trying to accomplish
  • Error messages from application logs
  • Steps you've already tried
  • Relevant code snippets (if not sensitive)

Before Contacting Support:

  • Check application and error logs for specific error messages
  • Verify all files are uploaded correctly
  • Ensure gems are installed properly (bundle install)
  • Test with a simple "Hello World" application first
  • Confirm your config.ru file is properly configured

Advanced Features

Multiple Ruby Applications:

  • Create separate applications for different projects
  • Each can use different Ruby versions and gem sets
  • Isolate development, staging, and production environments

Background Jobs:

  • Implement background processing with gems like Sidekiq
  • Schedule tasks using cron jobs in cPanel
  • Process data asynchronously

API Development:

  • Create RESTful APIs using Sinatra or Rails API mode
  • Implement proper HTTP status codes and JSON responses
  • Add authentication and rate limiting

Summary

The CloudLinux Setup Ruby App tool provides a powerful yet user-friendly way to deploy Ruby applications on premium hosting. By following this guide, you can successfully deploy Sinatra applications, Rails projects, or custom Rack applications without complex server configuration. Remember to test thoroughly, follow Ruby best practices, monitor your application logs, and don't hesitate to contact support if you need assistance with your Ruby applications.

Quick Jump Menu