April 14, 2026 • 12 min read

Deploying Next.js with PM2 on Ubuntu 24.04 – Full Guide

One of the biggest challenges when deploying Node.js apps is keeping them running after you close your terminal or reboot the server. That’s where PM2 comes in.

In this lab, I installed Node.js using NVM, created a Next.js app, built it for production, and used PM2 to manage the process. I also configured PM2 to automatically start after every server reboot using systemd.

Key Commands I Used

pm2 start npm --name "vibe-next-app" -- start
pm2 save
pm2 startup

PM2 now watches my app, restarts it if it crashes, and keeps it alive even when the VPS reboots. Combined with Nginx reverse proxy, this gives me a solid production setup on a small 1GB RAM VPS.