Docs / Programming & Development / Setting Up Ruby on Rails with Puma and Nginx

Setting Up Ruby on Rails with Puma and Nginx

By Admin · Feb 9, 2026 · Updated Apr 23, 2026 · 4 views · 3 min read

In this article, we'll walk through the complete process of working with rails in a server environment. Understanding puma is essential for maintaining a reliable and performant infrastructure.

Prerequisites

  • Root or sudo access to the server
  • A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
  • Git installed on the server

Environment Setup

Regular maintenance is essential for keeping your rails installation running smoothly. Schedule periodic reviews of log files, disk usage, and security updates to prevent issues before they occur.


# Set up the development environment
sudo apt update
sudo apt install -y build-essential curl git

# Install the runtime
curl -fsSL https://get.rails.org | bash
rails --version

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

Project Configuration

Regular maintenance is essential for keeping your rails installation running smoothly. Schedule periodic reviews of log files, disk usage, and security updates to prevent issues before they occur.


# Create a systemd service for the application
sudo tee /etc/systemd/system/myapp.service << 'EOF'
[Unit]
Description=My Application
After=network.target

[Service]
User=deploy
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/rails /opt/myapp/server.js
Restart=always
Environment=NODE_ENV=production
Environment=PORT=3000

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable myapp
sudo systemctl start myapp

The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.

Important Notes

The puma component plays a crucial role in the overall architecture. Understanding how it interacts with rails will help you make better configuration decisions.

  • Use connection pooling for database connections
  • Start with the minimum required resources
  • Profile before optimizing - measure first
  • Implement caching at every appropriate layer
  • Scale vertically before scaling horizontally

Deployment Process

Security should be a primary consideration when configuring rails. Always use strong passwords, keep software updated, and restrict network access to only the necessary ports and IP addresses.


# Set up the development environment
sudo apt update
sudo apt install -y build-essential curl git

# Install the runtime
curl -fsSL https://get.rails.org | bash
rails --version

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

Wrapping Up

Following this guide, your rails setup should be production-ready. Keep an eye on resource usage as your traffic grows and don't forget to test your backup and recovery procedures periodically.

Was this article helpful?