Chat with Musaddaq 💬
musaddaq.dev
ServicesIndustriesProcessPortfolioEstimatorBlogContact
Let's Talk
Back to All Articles
DevOps

Complete Guide: Deploying Next.js 16 on Ubuntu VPS with Nginx & PM2

Musaddaq Farid TahirMusaddaq Farid Tahir
•August 18, 2026•7 min read
Complete Guide: Deploying Next.js 16 on Ubuntu VPS with Nginx & PM2

Table of Contents

Why Self-Hosted VPS Deployment?PrerequisitesStep 1: Install Node.js & PM2Step 2: Configure Nginx Reverse ProxyStep 3: Enable SSL Certificate with Certbot

Why Self-Hosted VPS Deployment?

While platforms like Vercel are great for quick prototypes, hosting your client applications on a dedicated VPS gives you full control over CPU resources, custom background workers, and zero bandwidth overage costs.

Prerequisites

1. Ubuntu 24.04 LTS VPS instance

2. Registered domain name pointed to your VPS IP address

3. SSH terminal access

Step 1: Install Node.js & PM2

Log in to your server and run the following shell setup:

bash
# Update system repositories
sudo apt update && sudo apt upgrade -y

# Install Node.js v20 LTS
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs nginx git

# Install PM2 Process Manager globally
sudo npm install -y -g pm2

Step 2: Configure Nginx Reverse Proxy

Create an Nginx configuration file at `/etc/nginx/sites-available/musaddaq.dev`:

nginx
server {
    server_name musaddaq.dev www.musaddaq.dev;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Step 3: Enable SSL Certificate with Certbot

bash
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d musaddaq.dev -d www.musaddaq.dev

Now your custom Next.js application is running securely on production HTTPS!

Need Custom Web Engineering?

Let's build your Next.js project today

WhatsApp Direct: 03111122125

Chat on WhatsApp
musaddaq.dev

Delivering high-end, custom Next.js web applications engineered for extreme speed, rock-solid security, and zero monthly plugin headaches.

Navigation

  • Services & Comparison
  • Industries We Serve
  • Our 4-Step Process
  • Live Portfolio
  • Project Estimator
  • Contact Us

Blog & Articles

  • Browse All Articles →
  • Next.js 16 vs WordPress Benchmark
  • Ubuntu VPS Deployment Guide
© 2026 musaddaq.dev. All rights reserved.