Template

Node.js Server

Node.js from nodejs.org, PM2 to keep apps running, and Nginx in front.

Steps, in order · version 1.0

  1. Update Packages
  2. Install Node.js
  3. Install Nginx (optional)

Supported systems

Ubuntu 22.04+, Debian 12+, RHEL-compatible 8+ (AlmaLinux, Rocky Linux, RHEL, CentOS Stream, Oracle Linux), Amazon Linux 2023+. Still runs on Ubuntu 20.04 and Debian 11, which are past the end of standard support.

Options

As they appear on the run form, with their defaults.

Node.js version

One choice

  • Node.js 24 (LTS)
  • Node.js 22 (LTS, maintenance)

Default: Node.js 24 (LTS)

Install PM2

On or off

Default: On

Install Nginx

On or off

Default: On

What you get

A server ready for Node.js applications: Node.js from nodejs.org, checked against its published checksum, PM2 to keep applications running, and Nginx to put in front of them. The template does not deploy an application or configure a site.

Choosing the options

Node.js version: Node.js 24 (LTS) for new applications; Node.js 22 when a dependency does not support 24 yet.

Install PM2: keeps your applications running and restarts them if they crash. Leave it on unless you run applications as systemd services.

Install Nginx: to serve the application on ports 80 and 443 through a reverse proxy. Turn it off if another server or a load balancer sits in front.

What happens

  1. Update Packages.
  2. Install Node.js, with PM2 as a global package when chosen.
  3. Install Nginx, when chosen.

After the run

  1. Deploy the application and install its dependencies (npm ci).
  2. Start it with PM2, listening on a local port such as 3000: pm2 start npm --name shop -- start, then pm2 save and pm2 startup so it starts again after a reboot.
  3. Put HTTPS in front with Configure Reverse Proxy, forwarding to http://127.0.0.1:3000.
  4. Add a website monitor in Monitoring.

Common problems