DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

How to Use Capistrano 3 to Automate Deployments to a VPS

A practical Capistrano 3 guide for deploying Ruby or Rails applications to a VPS, covering server preparation, stage configuration, shared paths, dry runs, releases, and rollback.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capistrano automates a deployment procedure you would otherwise perform manually over SSH. You run it from your application’s Ruby bundle, select a stage such as production, and it connects to the VPS to fetch code, build a release, link persistent files, run application tasks, and move a current symlink to the new release. A reliable setup therefore has two parts: a correctly prepared VPS and stage-specific Capistrano configuration.

This guide shows how to prepare the server, initialize Capistrano 3, configure production and Rails integrations, test safely, understand the releases/shared/current layout, and roll back when a release is unusable.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What Capistrano does (and does not do)

Capistrano is a Ruby, Rake, and SSH deployment automation framework. The command is run from your project, normally through Bundler:

bundle exec cap production deploy

Capistrano then executes the tasks defined by your application and its plugins on the remote VPS. The normal flow checks prerequisites, creates a new release directory, checks out the configured source revision, runs configured tasks such as dependency installation or migrations, links shared paths, publishes the release by moving current, and removes old releases according to your retention setting.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

It does not provision a VPS, install an operating system, create a database, configure DNS, or replace a process manager. Those jobs must already be handled on the server. Capistrano makes a repeatable SSH procedure, rather than hiding the underlying operations; the project documentation describes this as having “no magic.”

Prerequisites and responsibilities

Area What you need
Local development machine Ruby compatible with the Capistrano release, Bundler, your application source-control checkout, and the project’s bundle.
Capistrano compatibility The official quick start documents Ruby 2.5 or newer. Verify that prerequisite against the Capistrano version you pin and the Ruby version actually installed on your machine and VPS.
VPS An SSH-accessible POSIX server with Ruby/Bundler and the application’s runtime dependencies installed.
Source control Git or the SCM selected for the project, with its binaries available where Capistrano runs the checkout.
Access A dedicated non-privileged deployment user, SSH key authentication, and permission to write the application’s deployment directory.
Application operations A running database and service/process-manager arrangement, plus any web-server, firewall, TLS, and monitoring configuration your application requires.

Use a non-interactive SSH session. A deployment that waits for a password, an interactive sudo prompt, or a shell profile question will stop unattended execution. Grant narrowly scoped privileges instead of making the deployment user an administrator.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare the VPS

  1. Create the deployment account. Add a dedicated user that is not used for routine administration. Give it ownership of the application parent directory, for example /var/www/my_app, and only the extra groups or commands the application genuinely needs.
  2. Install the runtime. Install the Ruby version supported by the application and Capistrano, Bundler, native libraries required by gems, and any runtime services the application uses. Keep the Ruby and Bundler versions consistent with the lockfile and your local deployment bundle.
  3. Install the SCM client. Install Git, or the binary for the SCM configured in your Capistrano setup. The remote checkout cannot succeed if that executable is missing.
  4. Install the SSH key. Put the public key used by the deployment machine in the deployment user’s authorized_keys, verify directory and file permissions, and test a non-interactive connection before writing Capistrano configuration.
  5. Create the parent directory. The deployment user must be able to create the Capistrano hierarchy below the path you choose for :deploy_to. Do not place that path in a temporary directory that is routinely cleaned.
  6. Prepare external services. Create the production database, ensure the process manager and web server can restart or reload the application, and decide where secrets and user uploads will live. Capistrano can run application tasks, but it does not create these services for you.

Test the exact account and host that will appear in the stage file. For example, confirm that an SSH command using the deployment key can start the server’s normal POSIX shell without prompting for input.

Install and initialize Capistrano in the project

Add Capistrano to the development bundle rather than the application’s runtime dependency list:

group :development do
  gem "capistrano", require: false
end

Pin a version compatible with your Ruby and application, then install the bundle:

bundle install

From the project root, generate the standard configuration:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
bundle exec cap install

Initialization creates a Capfile, a shared config/deploy.rb, and stage files such as config/deploy/production.rb and config/deploy/staging.rb. Treat these as templates. Replace sample application names, repository addresses, users, hosts, branches, and paths with values for your own VPS.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Configure the common deployment policy

Put settings that apply to every stage in config/deploy.rb. A minimal policy looks like this:

set :application, 'my_app'
set :repo_url, '[email protected]:team/my_app.git'
set :branch, 'main'
set :deploy_to, '/var/www/my_app'

append :linked_dirs,
       'log',
       'tmp/pids',
       'tmp/cache',
       'tmp/sockets',
       'public/uploads',
       'vendor/bundle'

append :linked_files,
       'config/database.yml',
       'config/secrets.yml'

Choose the repository and branch deliberately

:repo_url must be reachable by the account performing the checkout. If the repository is private, configure a deploy key or another non-interactive authentication method on the VPS; never depend on a developer’s personal SSH agent being present during an unattended deployment. Set a branch policy that matches your release process. A fixed production branch is easier to audit than an accidental checkout of whatever branch happened to be active locally.

Set a stable deployment root

:deploy_to is the parent directory for all Capistrano data. Keep it stable across releases and make it writable by the deployment user. The value should not include a trailing path that changes between stages unless you intentionally want separate trees.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Declare persistent directories and files

Use append :linked_dirs for data that must survive a new checkout: logs, PID and socket locations, caches, uploads, and a shared Bundler directory when your deployment needs it. Use append :linked_files for files that are not stored in the repository, such as database connection settings or application secrets. Capistrano creates symlinks from shared into each release.

Create every required shared file before the first deployment, with ownership and permissions that allow the application process to read it. Do not commit production secrets merely to make a symlink target exist. Conversely, do not mark an ordinary source file as linked: Capistrano will expect its target in shared and the deployment will fail if that target is absent.

Define the production stage

Keep host-specific values in config/deploy/production.rb so staging can point to another machine and use different settings:

server '203.0.113.10',
       user: 'deploy',
       roles: %w[app db web]

set :stage, :production

Replace the example address with the VPS hostname or IP and use the deployment account you tested. Roles are labels used by tasks to decide where work runs; assign only the roles your application and integrations need. If your application has separate application and database hosts, declare each server explicitly rather than assuming all roles share one machine.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

A staging file can use the same common policy while changing the host, branch, deployment root, and any non-production service settings. Always invoke the intended stage in the command; production and staging are separate configuration contexts.

Load the integrations your application needs

Capistrano’s core handles deployment orchestration. Plugins add framework-specific tasks. In Capfile, load only the integrations you use:

require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/bundler'
require 'capistrano/rails'

Bundler integration

capistrano/bundler runs the bundle installation policy during deployment. If the project relies on a shared Bundler configuration, include .bundle in :linked_dirs alongside vendor/bundle, after confirming that the configuration contains no machine-specific or secret values that should not be shared.

Rails integration

capistrano/rails provides Rails deployment tasks, including cap deploy:migrate and cap deploy:compile_assets. You can require only the assets and migrations integrations when you do not need the rest of the Rails plugin. Typical Rails persistent paths include log, tmp/pids, tmp/cache, tmp/sockets, vendor/bundle, .bundle, and upload directories. Typical persistent files include config/database.yml and config/secrets.yml; choose paths according to the actual Rails version and secret-management design of your application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand the Capistrano directory hierarchy

For a deployment root such as /var/www/my_app, Capistrano separates immutable release checkouts from mutable shared state:

Path Purpose What changes during deployment
releases/ One directory per successful or in-progress checkout. A new release directory is created; old ones are removed according to retention settings.
shared/ Persistent files and directories such as secrets, logs, sockets, and uploads. Contents remain while releases are replaced; linked entries in each release point here.
current Symlink consumed by your process manager or web server. It moves to the newest successfully published release.

Your service should run from current, not from a numbered release path. This makes publication and rollback an atomic symlink change and prevents a process restart from accidentally selecting an older checkout. Persistent user data belongs in shared or an external storage service, never only inside a release directory that cleanup may delete.

Inspect a deployment before changing the server

From the project root, inspect prerequisites and task execution first:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
bundle exec cap production deploy --prereqs
bundle exec cap production deploy --dry-run

--prereqs helps you inspect task dependencies. The dry run shows the task sequence without applying the deployment changes to the server. Review the selected stage, host, user, repository, branch, linked paths, and any commands that would restart services. A dry run cannot prove that credentials, permissions, native libraries, or application data are correct, so treat it as a configuration check rather than a complete deployment test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When the output is unclear, add tracing:

bundle exec cap production deploy --trace

After the dry run and a successful SSH check, perform the real deployment:

bundle exec cap production deploy

Watch the output until Capistrano publishes current. Then check the application through its normal health endpoint or user-facing path, inspect the service logs, and verify that background workers and scheduled jobs are using the new release as intended.

Control release retention and service behavior

Keep enough releases to recover from a bad application change, but do not retain unbounded copies of large assets. Set a retention count appropriate to the VPS disk budget and your recovery window. Cleanup should remove old release directories only after the new release has been published; never store uploads, logs, or secrets exclusively under releases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capistrano publishes code by changing the current symlink. It does not automatically restart every process manager or web server. Configure an explicit restart or reload task for the services that need one, and make that task safe to run repeatedly. If a service continues using old code after publication, the deployment may have succeeded while the running process still points at an earlier process state.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Roll back an unusable release

If the newly published release fails its health check, stop accepting traffic or follow your incident procedure first. Then invoke Capistrano’s rollback task for the production stage:

bundle exec cap production deploy:rollback

The rollback changes current back to a previous release retained under releases. Restart or reload the application service if your process manager does not notice the symlink change automatically, and verify the health check again.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Rollback restores code; it does not repair a misconfigured VPS, recreate a missing linked file, undo an irreversible database migration, or recover an upload deleted outside shared. Keep database migrations backward-compatible when possible, back up production data independently, and correct the configuration or shared-state problem before attempting another deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common failures

SSH authentication or host-key errors

Confirm that the stage’s user and host match the account tested manually, that the deployment key is available to the process running Bundler, and that the VPS accepts the key without an interactive prompt. Check the deployment user’s home, .ssh permissions, and known-host policy.

Repository checkout fails

Verify the repository URL, branch name, SCM binary, and repository credentials from the deployment account’s environment. A successful checkout on your laptop does not prove that the VPS can reach a private repository.

Permission denied under the deployment root

Inspect ownership of the parent directory and existing releases, shared, and current entries. Avoid fixing this by running the whole deployment as root; correct ownership or grant the narrow permission the task requires.

A linked file or directory is missing

Create the expected target under shared with correct ownership and mode, or remove the path from :linked_files or :linked_dirs if it is not actually persistent. Confirm that the relative path matches the application’s runtime expectation exactly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bundle, asset, or migration task fails

Check Ruby and Bundler compatibility, native package dependencies, environment variables, database connectivity, and the plugin requirements loaded in Capfile. Run the failing task manually as the deployment user only to isolate the dependency; keep the final procedure in Capistrano so later deployments remain repeatable.

The deployment succeeds but the site still serves old code

Confirm that the process manager starts the application from current, that the symlink points to the new release, and that the configured restart or reload task actually ran. Also check reverse-proxy caching and background workers separately.

Production checklist

  • Ruby and Bundler versions satisfy the pinned Capistrano and application dependencies.
  • The VPS has the selected SCM binary and all runtime and native dependencies.
  • The deployment account uses SSH keys, a POSIX shell, and no interactive privilege escalation.
  • :repo_url, :branch, :deploy_to, host, user, and roles are correct for the selected stage.
  • Every linked file and directory has an intentional target in shared.
  • Secrets are outside source control and readable by the application process.
  • The service runs from current and has an explicit, repeatable reload or restart task.
  • A dry run, prerequisite inspection, health check, log check, and rollback procedure have been exercised on staging or a maintenance window.
  • Release retention leaves enough known-good releases while respecting disk capacity.

When Capistrano is a good fit

Capistrano is especially practical when you already operate one or a small number of SSH-accessible VPS instances and want predictable release directories, shared persistent paths, multiple stages, and a straightforward code rollback. It assumes servers are provisioned and maintained separately. Workflows based on prebuilt images, container schedulers, or artifact registries may be preferable when an organization needs immutable infrastructure, automated fleet provisioning, or orchestration across many machines; those approaches use different mechanisms for artifacts, secrets, health checks, and rollback.

For a single VPS, the key design decision is not the command itself but the boundary between release content and persistent state. Keep code in numbered releases, keep secrets and mutable data in shared or external storage, make service reloads explicit, and test the exact production stage before publishing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.