Docs / Programming & Development / Setting Up a Ruby on Rails Application

Setting Up a Ruby on Rails Application

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 26 views · 1 min read

Prerequisites

sudo apt update
sudo apt install -y build-essential libssl-dev libreadline-dev zlib1g-dev \
  libsqlite3-dev libpq-dev nodejs npm

Install Ruby with rbenv

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc
source ~/.bashrc

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install 3.3.0
rbenv global 3.3.0

gem install rails

Deploy Your App

cd /var/www
git clone https://github.com/you/myapp.git
cd myapp
bundle install --deployment --without development test
RAILS_ENV=production rails db:migrate
RAILS_ENV=production rails assets:precompile

Puma Configuration

# config/puma.rb
workers ENV.fetch("WEB_CONCURRENCY", 2)
threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
threads threads_count, threads_count
bind "unix:///var/www/myapp/tmp/sockets/puma.sock"
environment "production"

Systemd Service

[Unit]
Description=Rails Puma
After=network.target

[Service]
User=deploy
WorkingDirectory=/var/www/myapp
ExecStart=/home/deploy/.rbenv/shims/bundle exec puma -C config/puma.rb
Restart=always
Environment=RAILS_ENV=production
Environment=SECRET_KEY_BASE=your_secret_key

[Install]
WantedBy=multi-user.target

Was this article helpful?