How to Deploy PhrasePhantoms RoR WebApp on Ubuntu 20.04 | 22.04 | 24.04 in 2025 – The Ultimate Step-by-Step Guide
From setting up your server and configuring NGINX to deploying with Capistrano. Learn how to deploy PhrasePhantoms, a Ruby on Rails web app, on Ubuntu 20.04, 22.04, and 24.04 in 2025 with this ultimate step-by-step guide.
In this guide, I’ll walk you through the entire deployment process—from choosing the best server and installing essential dependencies to configuring NGINX, setting up your PostgreSQL/MySQL database, and deploying your app with Capistrano.
Whether you're deploying your first Rails app or looking to optimize your workflow in 2025, this guide will help you launch your application smoothly and securely.
1. Choosing a Server Hosting Provider & Domain Name.
Your hosting provider is the foundation of your web application. You need a reliable, high-performance server that can handle traffic, security, and uptime without breaking the bank.
Unlike managed hosting services (which limit server control and are often outdated), self-managed VPS (Virtual Private Server) hosting gives you full control over your environment. This means you can configure everything exactly how you need it for a smooth and secure Rails deployment.
step 1: Top Recommended Hosting Providers for Ruby on Rails
Here are some of the best VPS providers for hosting your Rails app:
-
- DigitalOcean (Recommended!) – Affordable, fast, and super easy to use. Plus, you get $100 free credit when you sign up!
- Linode – Solid performance and pricing, good for developers.
- Vultr – Great speed and low latency, perfect for web apps.
- Amazon EC2 – A scalable option for advanced users.
- Amazon LightSail – Simple and beginner-friendly cloud hosting.
- Google Cloud – Powerful, but has a steeper learning curve.
- Microsoft Azure – Enterprise-level cloud hosting.
- Any VPS provider offering Ubuntu with root access – If it gives you full server control, you’re good to go! Step 2: Registering a Domain Name
Before your app goes live, you need a domain name so people can access it easily.
We highly recommend using Kenya Web Experts for domain registration. They offer great support, fast domain activation, and competitive pricing. Alternatively, you can register a domain on any major platform like GoDaddy, Namecheap, or Google Domains.
Step 2. Create a virtual server - Droplets
It's time for us to create our server. Open up DigitalOcean and go to the Create Droplet page. Droplets are virtual machines that anyone can setup in seconds. You can use droplets, either standalone or as part of a larger, cloud based infrastructure.
step 1 : choose your location.
Select the datacenter closest to you or your users. Avoid any potential latency by selecting a region closest to you - a region is a geographic area where we have one or more datacenters.
Step 2: Choose your operating system:
We want to use Ubuntu 22.04 for our server's operating system. It's an long-term support (LTS) release which means it will receive security updates for several more years than normal. This is crucial for production. Choose Ubuntu 22.04
from the dropdown in the Choose an image section.
Step 3: Choose the Right Server Size for Your Needs
Picking the right server size is crucial for performance and scalability. Under the "Choose a size" section, select a server that fits your current needs and budget.
💡 Not sure which size to choose? Start with a 2GB RAM server—it’s a solid choice for most applications. The best part? You can upgrade anytime without losing your data! Since these are virtual servers, you can easily scale up by adding more RAM or CPUs as your traffic grows.
Step 4 : Choose Authentication Method.
For security and best practices, SSH Key Authentication is the recommended method when connecting to your Droplet (VPS). Follow these instructions to create or add SSH keys on Linux.
Create a new key pair, if needed
Open a terminal and run the following command:
ssh-keygen
You will be prompted to save and name the key.
Generating public/private rsa key pair. Enter file in which to save the key (/Users/USER/.ssh/id_rsa):
Next you will be asked to create and confirm a passphrase for the key (highly recommended):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
This will generate two files, by default called id_rsa
and id_rsa.pub
. Next, add this public key.
Add the public key
Copy and paste the contents of the .pub file, typically id_rsa.pub, into the SSH key content field.
cat ~/.ssh/id_rsa.pub.
If you’re serious about security and best practices: Use SSH Key Authentication. If you just need quick access and will set up SSH keys later: Use Password Authentication temporarily, then switch to SSH keys.
Step 5: Optional settings.
You can enable a few other options if you choose:
-
-
Backups (optional) - Backups up your entire server to an image that you can restore from. These usually don't run very often, so you can skip these if you want. Hourly database backups are more useful.
-
Additional Storage (optional ) - Block storage volumes add extra disk space. We automatically format and mount your volume so it’s available as soon as your Droplet is, and you can move volumes seamlessly between Droplets at any time. Think of it like a flash drive for your VM.
-
Add improved metrics monitoring and alerting (free): check this one. This is useful to get some rough metrics of server usage.
-
Add a worry-free Managed Database (+$15.00) (optional): leave this one unchecked. includes daily backups with PITR, automated failover, and end-to-end SSL.
-
IPv6 (recommended) - Enable this to give your server an IPv6 address. Can't hurt.
-
Step 6: Finalize Details.
Your hostname is simply a name to help you identify your Droplet, for consistent naming. Adding tags helps you group and manage your servers more efficiently.
.
When deploying a Ruby on Rails app with services like ElasticSearch, Redis, and a database (such as PostgreSQL or MySQL), the amount of RAM your server has will be a key factor in your app’s performance and scalability. As your app gains users and more services are added, you’ll need to scale your server. The main resource to keep an eye on is RAM – and you’ll likely need to increase it as you add more components, especially if your app becomes more resource-hungry.
Step 2 — Logging in as root.
To log into your server, you will need to know your server’s public IP address.
If you are not connected to your server currently, log in as the root user using the following command. Substitute the highlighted portion of the command with your server’s public IP address:
ssh root@your_server_ip
Accept the warning about host authenticity if it appears. If your server uses password authentication, provide your root password to log in. If you use an SSH key that is passphrase protected, you may need to enter the passphrase the first time you use the key each session. If this is your first time logging into the server with a password, you may also need to change the root password. Follow the instructions to change the password if you receive a prompt.
About root
The root user is the administrative user in a Linux environment with elevated privileges. Because of the heightened privileges of the root account, you are discouraged from using it regularly. The root account can make very destructive changes, even by accident.
The next step is setting up a new user account with reduced privileges for day-to-day use. Later, we’ll show you how to temporarily gain increased privileges for the times when you need them.
Step 1 — Creating a New User
Once you log in as root, you’ll be able to add the new user account. In the future, we’ll log in with this new account instead of root.
This example creates a new user called sammy, but you should replace that with a username that you like:
adduser johnson
You will be asked a few questions, starting with the account password.
Enter a strong password and, optionally, fill in any additional information you would like. This information is not required, and you can press ENTER
in any field you wish to skip.
root@phrasephantoms:~# adduser zabu
Adding user `zabu' ...
Adding new group `zabu' (1000) ...
Adding new user `zabu' (1000) with group `zabu' ...
Creating home directory `/home/zabu' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for zabu
Enter the new value, or press ENTER for the default
Full Name []: Johnson Githuku chege
Room Number []:
Work Phone []: 0726905640
Home Phone []:
Other []:
Is the information correct? [Y/n] y
Step 3 — Granting Administrative Privileges
Now you have a new user account with regular account privileges. However, you will sometimes need to perform administrative tasks as the root user.
To avoid logging out of your regular user and logging back in as the root account, you can set up what is known as superuser or root privileges for your user’s regular account. These privileges will allow your normal user to run commands with administrative privileges by putting the word sudo
before the command.
To add these privileges to your new user, you will need to add the user to the sudo system group. By default on Ubuntu, users who are members of the sudo group are allowed to use the sudo
command.
As root, run this command to add your new user to the sudo group (substitute the highlighted username with your new user):
usermod -aG sudo sammy
You can now type sudo
before commands to run them with superuser privileges when logged in as your regular user.
Step 4 — Setting Up a Firewall
Ubuntu servers can use the UFW firewall to ensure only connections to certain services are allowed. You can set up a basic firewall using this application.
Applications can register their profiles with UFW upon installation. These profiles allow UFW to manage these applications by name. OpenSSH, the service that allows you to connect to your server, has a profile registered with UFW.
You can examine the list of installed UFW profiles by typing:
ufw app list
Output
Available applications:
OpenSSH
You will need to make sure that the firewall allows SSH connections so that you can log into your server next time. Allow these connections by typing:
ufw allow OpenSSH
Now enable the firewall by typing:
ufw enable
Type y
and press ENTER
to proceed. You can see that SSH connections are still allowed by typing:
ufw status
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
The firewall is currently blocking all connections except for SSH. If you install and configure additional services, you will need to adjust the firewall settings to allow the new traffic into your server.
Step 5 — Enabling External Access for Your Regular User
Now that you have a regular user for daily use, you will need to make sure that you can SSH into the account directly.
Note: Until verifying that you can log in and use sudo
with your new user, we recommend staying logged in as root. If you have problems connecting, you can troubleshoot and make any necessary changes as root. If you use a DigitalOcean Droplet and experience problems with your root SSH connection, you can regain access to Droplets using the Recovery Console.
Configuring SSH access for your new user depends on whether your server’s root account uses a password or SSH keys for authentication.
If the root Account Uses Password Authentication
If you logged in to your root account using a password then password authentication is enabled for SSH. You can SSH to your new user account by opening up a new terminal session and using SSH with your new username:
ssh johnson@your_server_ip
After entering your regular user’s password, you will be logged in. Remember, if you need to run a command with administrative privileges, type sudo
before it like this:
sudo command_to_run
You will receive a prompt for your regular user’s password when using sudo
for the first time each session (and periodically afterward).
To enhance your server’s security, we strongly recommend setting up SSH keys instead of using password authentication.
If the root Account Uses SSH Key Authentication
If you logged in to your root account using SSH keys, then password authentication is disabled for SSH. To log in as your regular user with an SSH key, you must add a copy of your local public key to your new user’s ~/.ssh/authorized_keys
file.
Since your public key is already in the root account’s ~/.ssh/authorized_keys
file on the server, you can copy that file and directory structure to your new user account using your current session.
The simplest way to copy the files with the correct ownership and permissions is with the rsync
command. This command will copy the root user’s .ssh
directory, preserve the permissions, and modify the file owners, all in a single command. Make sure to change the highlighted portions of the command below to match your regular user’s name:
Note: The rsync
command treats sources and destinations that end with a trailing slash differently than those without a trailing slash. When using rsync
below, ensure that the source directory (~/.ssh
) does not include a trailing slash (check to make sure you are not using ~/.ssh/
).
If you accidentally add a trailing slash to the command, rsync
will copy the contents of the root account’s ~/.ssh
directory to the sudo
user’s home directory instead of copying the entire ~/.ssh
directory structure. The files will be in the wrong location and SSH will not be able to find and use them.
rsync --archive --chown=sammy:sammy ~/.ssh /home/sammy
Now, open up a new terminal session on your local machine, and use SSH with your new username:
ssh sammy@your_server_ip
You should be connected to your server with the new user account without using a password. Remember, if you need to run a command with administrative privileges, type sudo
before the command like this:
sudo command_to_run
You will be prompted for your regular user’s password when using sudo
for the first time each session (and periodically afterward).
Tags::
Johnson Chege
This user hasn't provided a description yet.
0 Comments