Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween 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
VGSources
Blog

How to Deploy a Rails App with Passenger and Apache on a VPS

A practical, production-conscious guide to deploying Rails with Passenger and Apache on a VPS, including installation routes, users, virtual hosts, sub-URI hosting, verification, and failure diagnosis.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable deployment shape is straightforward: install Apache and Passenger on the VPS, keep the Rails code in a persistent directory owned by a non-root deployment user, and point the Apache virtual host’s DocumentRoot to the app’s public directory. Set PassengerRuby to the exact Ruby interpreter your application needs, grant Apache access to that directory, disable MultiViews, restart Apache, and validate the installation. The remaining work—database setup, credentials, DNS, TLS, and repeatable releases—must match your application and operating system.

What this deployment does

Apache receives the HTTP request for your domain. Passenger, loaded into Apache, starts and supervises the Rails application process, selects the Ruby interpreter configured for the virtual host, and forwards dynamic requests to Rails. Static files can be served directly from the Rails public directory. This arrangement keeps the web server, application code, Ruby runtime, and database on one VPS while leaving you responsible for operating all of them.

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.

Passenger’s installation and deployment documentation covers the Apache integration and the virtual-host layout. It does not constitute a complete security, HTTPS, backup, monitoring, or release-management runbook. Treat those as separate production work.

Decide the layout before installing anything

Minimum prerequisites

Requirement What you need to decide
VPS operating system Use a currently supported Linux distribution and its package manager. Passenger package names and repository identifiers change, so select the distribution in Passenger’s current installation selector.
Administrative access An SSH account with sudo privileges. Do not run the Rails application as root.
Web server Apache installed and able to bind the HTTP port.
Ruby The Ruby version required by the application’s lockfile and Rails version. There may be more than one Ruby on the machine.
Application dependencies Git, compiler/build prerequisites required by native gems, Bundler, and any JavaScript or asset tooling required by the application.
Database The database service and client libraries required by the app. The Rails application determines the engine, database name, user, migrations, and connection settings.
Public name A DNS record that resolves the intended hostname to the VPS address. You can test by IP first, but the final virtual host should use the real name.

Reserve a persistent application path such as /var/www/myapp. Keeping code outside a temporary build directory prevents a reboot, cleanup job, or package update from deleting the deployed application.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Provision Apache, Ruby, Git, and the database

Connect to the server over SSH and update the operating system using its normal security-update process. On a Debian- or Ubuntu-family system, the first package operation is typically:

sudo apt update

Install Apache and Git with the distribution package manager, then install the Ruby runtime and build prerequisites required by the chosen Passenger route and by your Gemfile. Package names differ across distributions and releases; use the current Passenger installation selector rather than copying an old repository line. Install the database service required by the application and verify that it starts at boot.

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

Do not assume that the Ruby used by your interactive shell is the Ruby Passenger will use. A system Ruby, an rbenv Ruby, and an RVM Ruby can coexist. Record the full path of the interpreter that can load your application’s bundle; you will place that path in PassengerRuby.

Install Passenger as an Apache integration

Passenger is not merely a gem that Rails loads. Apache must load Passenger’s module, and the module must be configured before Apache can launch the app.

Route 1: RubyGems module build

  1. Install the Passenger gem using the Ruby environment intended for the server.
  2. Run passenger-install-apache2-module. The installer checks prerequisites and builds the Apache module.
  3. At the end, copy the generated Apache configuration snippet into the appropriate Apache configuration. The snippet includes LoadModule, PassengerRoot, and related directives; use the paths printed for your machine rather than inventing them.

This route gives you control over the Passenger build, but you must maintain the gem and the generated Apache configuration yourself.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Route 2: Passenger’s distribution repository

Use Passenger’s current repository instructions for the exact Linux distribution and release, install the packaged Apache module, and let the package manager track its files. Repository distribution identifiers and prerequisite package names change over time, so an instruction written for another release can install the wrong module or fail signature checks.

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

Restart and validate

Restart Apache after installing the module. Then run Passenger’s official validation command:

sudo /usr/bin/passenger-config validate-install

Complete the checks it reports. If the command is not at that path, locate the Passenger executable installed by your package or Ruby environment and use the equivalent command. A successful gem installation without a successful Apache load is not a working deployment.

Create a non-root deployment user and retrieve the code

Create a dedicated account for the application. It should own the release files and have only the permissions needed to deploy and run the app; it should not be your SSH administrator account and should not be root.

  1. Create the persistent directory:
sudo mkdir -p /var/www/myapp
  1. Assign it to the deployment account (the example account is myappuser):
sudo chown myappuser: /var/www/myapp
  1. Check out the application as that user. The official layout places the Git working tree in a code subdirectory:
cd /var/www/myapp
sudo -u myappuser -H git clone https://github.com/username/myapp.git code

Replace the repository URL, branch, and account with your own values. If the server should deploy a specific branch or tag, check out that revision explicitly and document how it is changed. Keep secrets out of the repository.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Prepare Rails for production

Run the following operations as the deployment user, from the application directory, using the Ruby and Bundler versions required by the project:

  • Install the bundle according to the application’s deployment policy, commonly excluding development and test groups.
  • Set production credentials, environment variables, and any service endpoints through the mechanism chosen by the application. Do not put database passwords or master keys in a public Git repository.
  • Compile assets when the Rails version and asset pipeline require it.
  • Create the production database and run the application’s migrations or release task.
  • Verify file and directory ownership for anything Rails must write, such as logs, uploads, caches, or temporary files. Grant only the required write access.

There is no universal Rails command sequence for these steps: Rails versions, asset systems, credentials handling, and database adapters differ. Follow the application’s own release instructions and confirm that its production environment can boot before exposing it through Apache.

Choose the Ruby interpreter Passenger will run

When one Ruby is installed, the default may be sufficient. When several are installed, set the interpreter explicitly. Use Passenger’s tooling and the Ruby environment manager on the VPS to determine the absolute executable path that matches the application’s bundle, then put that path in the virtual host as PassengerRuby.

The path must be usable by the Apache process. A Ruby executable inside a user’s version-manager directory can fail if Apache cannot traverse the parent directories or read the installed gems. Test the path as the deployment user and check permissions before blaming Rails for a boot error.

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

Configure an Apache virtual host for a root deployment

Create a site configuration using the following pattern. Replace the hostname, application path, and Ruby path:

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
<VirtualHost *:80>
ServerName yourserver.com
DocumentRoot /var/www/myapp/code/public
PassengerRuby /path-to-ruby

<Directory /var/www/myapp/code/public>
Options -MultiViews
# Apache 2.4+:
Require all granted
# Apache 2.2 or configurations using access_compat:
# Allow from all
</Directory>
</VirtualHost>

Why each directive matters

  • ServerName: selects this host when the request’s hostname matches. The DNS record must point to the VPS.
  • DocumentRoot: ends in /public, the Rails application’s public subdirectory. Pointing at the repository root exposes the wrong directory and prevents Passenger’s expected layout from working.
  • PassengerRuby: selects the Ruby command for this virtual host instead of relying on an ambiguous system default.
  • Options -MultiViews: disables Apache content negotiation that can intercept extensionless Rails routes.
  • Directory authorization: Apache 2.4 uses Require all granted. Older Apache configurations use Allow from all; do not add obsolete directives blindly to a modern server unless its compatibility module is enabled.

Keep the application directory itself outside the web root; only the public directory is the document root. Passenger still needs to read the application code and its bundle, so filesystem permissions must allow the Apache/Passenger process to traverse and read those paths.

Enable the site, check syntax, and restart Apache

  1. Place the virtual-host file in the distribution’s Apache sites-available directory, or in the configuration location used by your distribution.
  2. Enable the site with the distribution’s Apache tooling if it uses a sites-enabled mechanism.
  3. Check the complete Apache configuration before disrupting the running service:
sudo apachectl configtest

Some distributions provide apache2ctl instead of apachectl. Continue only when the result reports a valid configuration. Fix a missing module, malformed directive, duplicate listener, or incorrect path before restarting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Restart Apache using the service manager command appropriate to the distribution, for example:
sudo systemctl restart apache2

Check the service status immediately after the restart. A failed restart means the old worker may still be serving traffic or the site may be unavailable; read the Apache error output before making another change.

Host a second Rails app under a sub-URI

A root virtual host is the simpler arrangement. If an application must live below a path such as /blog on an existing hostname, Passenger documents a different configuration using Alias, PassengerBaseURI, and PassengerAppRoot:

Alias /blog /var/www/myapp/code/public

<Location /blog>
PassengerBaseURI /blog
PassengerAppRoot /var/www/myapp/code
</Location>

<Directory /var/www/myapp/code/public>
Options -MultiViews
Require all granted
</Directory>

Use a matching Directory block for the second application’s public directory and ensure the Rails application is configured to generate URLs correctly below the chosen base path. Sub-URI hosting adds routing and asset-prefix concerns; a separate hostname and root virtual host is usually easier to reason about when you control DNS.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify the request path from DNS to Rails

Verification should isolate one layer at a time rather than treating a browser error as proof that Rails is broken.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Apache: confirm the service is active and that configtest succeeds.
  2. DNS: resolve the public hostname and confirm it returns the VPS address. If DNS has not propagated, test with the correct host header only in a controlled way; do not mistake the default Apache page for an application response.
  3. Virtual host selection: request the hostname and confirm Apache serves this site’s content rather than its default page.
  4. Passenger: use Passenger’s status and troubleshooting utilities where installed to see whether an application process was spawned and which Ruby it selected.
  5. Rails: inspect the Apache error log and the application’s production log for boot exceptions, missing gems, invalid credentials, migration failures, or asset errors.
  6. Database: test the production connection using the application’s supported task or health check. A web server can be healthy while every Rails request fails because the database is unavailable.
Symptom Likely checks
Default Apache page The hostname does not match ServerName, the site is not enabled, or another virtual host is first.
Apache will not restart Run apachectl configtest; check module names, directive spelling, duplicate listeners, and file paths.
Passenger application does not boot Verify PassengerRuby, bundle installation, application ownership, readable parent directories, credentials, and the production log.
403 Forbidden Check Apache’s authorization directive and every filesystem directory permission between /var/www and the public directory.
404 for Rails routes Confirm DocumentRoot is the app’s public directory, MultiViews is disabled, and the request reached the intended virtual host.
500 or 503 response Read Apache and Rails logs first; common causes include a failed boot, missing gem, unavailable database, invalid secret, or a Ruby mismatch.

Release new code without turning the VPS into a one-off

A first boot is only the starting point. Define a repeatable release sequence before accepting real traffic. A conservative manual sequence is:

  1. Fetch the intended Git revision as the deployment user.
  2. Install or update the locked bundle with the selected Ruby.
  3. Set or verify environment variables and credentials without printing secrets to the terminal or logs.
  4. Run the application’s asset compilation and database migration/release tasks when required.
  5. Check ownership and permissions for generated files.
  6. Use Passenger’s restart mechanism or restart Apache only when the application’s deployment method requires it, then make a health request and inspect logs.

For safer releases, build dependencies and assets in a separate release directory, switch a stable symlink, and retain the previous release for rollback. That pattern is an operational choice rather than a Passenger requirement; implement it only if your application and backup strategy support it.

Installation and architecture choices

Choice Advantages Trade-offs
Passenger package repository Distribution-managed files and upgrades; simpler integration with the operating system. Repository instructions and supported distribution identifiers must be kept current; less control over the build.
Passenger gem plus Apache module build Control over the Passenger version and build process; installer reports the exact Apache snippet. More manual maintenance of prerequisites, module paths, and upgrades.
System Ruby Fewer moving parts and straightforward service paths. May not match the Ruby version pinned by the application.
Version-managed Ruby Allows the app to use its required Ruby independently of the OS default. Apache must be able to access the version-manager path, and upgrades need an explicit PassengerRuby change or stable interpreter path.
Root virtual host Simple DNS, Apache, asset, and Rails URL behavior. Usually one app per hostname unless you add more virtual hosts.
Sub-URI deployment Can place multiple apps below one hostname. Requires Alias, PassengerBaseURI, PassengerAppRoot, and application URL-base coordination.
Self-managed VPS Full control of Apache, Ruby, Passenger, filesystem, and database. You operate patching, logs, backups, TLS, monitoring, scaling, and recovery.

Production responsibilities outside the basic Passenger recipe

Before calling the site production-ready, add the controls that the basic Apache/Passenger examples do not supply:

  • Terminate HTTPS and redirect HTTP according to your chosen certificate and renewal process.
  • Restrict SSH, keep the operating system and Passenger packages patched, and remove unused services.
  • Back up the database, uploaded files, credentials, and deployment configuration; test restoration rather than merely creating archives.
  • Monitor Apache, Passenger, disk space, memory, database health, and application errors.
  • Set log retention so a busy app cannot fill the VPS disk.
  • Define rollback and database-migration procedures before a failed release occurs.
  • Document DNS changes, Ruby upgrades, Passenger upgrades, and the exact command sequence used for a release.

The cited deployment material establishes the Apache integration, filesystem layout, and virtual-host requirements. It does not provide a complete security or uptime guarantee, and no particular VPS size, Rails version, Ruby version, database engine, or application has been tested here.

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.

Final deployment checklist

  • Apache, Ruby, Git, build prerequisites, and the application’s database service are installed.
  • Passenger’s Apache module is installed, Apache has been restarted, and passenger-config validate-install passes.
  • A dedicated deployment user owns a persistent path such as /var/www/myapp.
  • The application code and production bundle are present, and credentials and database preparation are complete.
  • PassengerRuby names the intended executable and Apache can traverse its path.
  • The virtual host’s DocumentRoot ends in the Rails app’s public directory.
  • The public directory allows Apache access and has Options -MultiViews.
  • The site is enabled, apachectl configtest succeeds, and Apache restarts cleanly.
  • DNS resolves to the VPS, the request selects the intended virtual host, and logs show a successful Rails boot.
  • HTTPS, backups, monitoring, patching, and a rollback procedure are planned before production traffic.

The Bottom Line

For a dependable Rails-on-VPS deployment, install and validate Passenger inside Apache, deploy the code under a dedicated user, point the virtual host at public, set the correct PassengerRuby, and verify the full DNS-to-database request path before adding production traffic.

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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
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.