Configuring a Ruby on Rails application on a shared hosting account
Learn how to use the Setup Ruby App feature in cPanel to configure and run a Ruby on Rails application.
Step 1: Create the application in cPanel
-
Log in to cPanel.
-
On the Tools page, in the Software section, click Setup Ruby App.
-
Under Setup New Application:
-
Select Ruby version 2.5.
-
In App Directory, type the directory name (example: railsapp).
-
Select your domain and enter the URI.
-
Click Setup.
-
-
Under Existing applications, locate your app.
-
In the modules row, click show.
-
In the field beside Add, type rails, then click Add.
-
Click Update to install the Rails module.
-
Copy the full source command shown next to Command for entering to virtual environment. You’ll need it for the next step.
Step 2: Configure the application from the command line
-
Log in using SSH.
-
Paste and run the source command you copied earlier to activate the virtual environment.
-
Run:
Bash
unset XDG_RUNTIME_DIR
-
Back up the config.ru file:
Bash
cd ~/railsapp
mv config.ru config.ru.bak
-
Create the Rails application:
Bash
rails new ~/railsapp
-
Open config/routes.rb and add this line after
Rails.application.routes.draw do:
root 'rails/welcome#index'
-
Save the file.
-
Go back to cPanel, locate the application under Existing applications, and click Restart.
-
Open your application’s URI in a browser. You should see the Yay! You're on Rails page.
Troubleshooting
-
Rails logs are located in:
~/railsapp/log -
Common files:
-
production.log
-
development.log
-
If you need more help, you can open a support ticket in your hosting control panel.
More information
-
Rails Getting Started Guide: guides.rubyonrails.org
-
Rails API Documentation: api.rubyonrails.org