Table of Contents
Setting Up Your VPS for Node.js
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
node --version # v20.x.x
npm install -g pm2PM2 — Production Process Manager
PM2 keeps your Node.js application running after crashes, manages logs, and provides a cluster mode for utilizing all CPU cores:
pm2 start app.js --name myapp
pm2 startup # auto-start on reboot
pm2 save
pm2 logs myapp # view logs
pm2 monit # real-time monitoringNGINX Reverse Proxy Configuration
server {
listen 80;
server_name yourdomain.com;
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;
}
}Zero-Downtime Deployments
PM2 cluster mode enables zero-downtime reloads: pm2 reload myapp. This restarts workers one at a time, ensuring continuous availability during deployments.
FAQ
How many Node.js apps can I run on a single VPS?
As many as your RAM allows. Each Node.js process typically uses 50-200 MB depending on the application. An 8 GB RAM VPS can comfortably run 10-20 smaller applications.
Ready to deploy?
Deploy Node.js on NVMe VPS
Dedicated vCores and NVMe storage optimized for Node.js applications.
