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

  1. Log in to cPanel.

  2. On the Tools page, in the Software section, click Setup Ruby App.

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

  4. Under Existing applications, locate your app.

  5. In the modules row, click show.

  6. In the field beside Add, type rails, then click Add.

  7. Click Update to install the Rails module.

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

  1. Log in using SSH.

  2. Paste and run the source command you copied earlier to activate the virtual environment.

  3. Run:

Bash
unset XDG_RUNTIME_DIR
  1. Back up the config.ru file:

Bash
cd ~/railsapp
mv config.ru config.ru.bak
  1. Create the Rails application:

Bash
rails new ~/railsapp
  1. Open config/routes.rb and add this line after Rails.application.routes.draw do:

root 'rails/welcome#index'
  1. Save the file.

  2. Go back to cPanel, locate the application under Existing applications, and click Restart.

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

Esta resposta foi útil? 0 Utilizadores acharam útil (0 Votos)

Powered by WHMCompleteSolution