Skip to main content
Rails comes with a config.ru already wired for Rack. The deployment loop is: install gems, precompile assets, run migrations, restart. For the underlying tool, see Ruby.

Before you begin

  • A Ruby app created in cPanel.
  • A Rails app at the application root, with Gemfile, config.ru, and config/environment.rb.
  • The Ruby version Passenger ships matches what your Gemfile declares. Check with ruby --version over SSH.

Deploy the app

1

Add the linux platform to your lockfile

From your dev machine:
bundle lock --add-platform x86_64-linux
git add Gemfile.lock && git commit -m "Add linux platform"
2

Install gems

Click Run Bundle Install in the cPanel app management page. Or from SSH:
cd ~/myapp
bundle config set deployment 'true'
bundle install
3

Precompile assets

Over SSH:
cd ~/myapp
RAILS_ENV=production bundle exec rake assets:precompile
If memory is tight, precompile on a dev machine and rsync public/assets/ up.
4

Run migrations

RAILS_ENV=production bundle exec rake db:migrate
5

Restart

Click Restart, or touch ~/myapp/tmp/restart.txt.

Set the secret base

Rails 5 and later require SECRET_KEY_BASE in production. Add to Environment variables in the cPanel UI:
SECRET_KEY_BASE=<generate with `bundle exec rake secret`>
Restart so the value picks up.

Common issues

bundle install ran against a different Ruby. Confirm with bundle env over SSH and re-run bundle install after activating the right Ruby.
Build assets locally, rsync public/assets/ and public/packs/ up. Skip the server-side precompile.
Use the cPanel database hostname (localhost typically works for MySQL on the same account). Username and database name come from the cPanel MySQL Databases page.
Long-running workers exceed the LVE NPROC ceiling. Move them to cron-driven one-shot jobs on a Basic plan, or upgrade.

Need a hand?

Open a ticket

Best for anything that needs an account check or a config change on our end.

Live chat

Faster for quick questions during business hours.