These steps take you from a bare Ubuntu 22.04 server to Strapi 5 running in production on PostgreSQL. Strapi is a headless CMS: your team edits content in its admin panel, and your website or app fetches that content through an API. The install itself is quick. What needs care is the setup around it: the Node version, the secret keys Strapi signs sessions with, and how the app stays up behind Nginx. You install Node 20 and Postgres, create the project, write its secrets to an env file and build the admin panel. Then you run it under PM2, a process manager that restarts Node apps and starts them at boot, with Nginx handling HTTPS in front. A last step moves uploaded files to object storage such as Amazon S3, so the setup can grow past one server.
How to verify
A correctly installed Strapi 5 in production mode shows:
curl -sI https://cms.example.org/admin/ | head -1
# HTTP/2 200
curl -s https://cms.example.org/api/_health
# (empty 204 — Strapi's liveness endpoint)
pm2 status
# ┌─────┬────────┬─────────┬─────┐
# │ id │ name │ status │ cpu │
# │ 0 │ strapi │ online │ 0% │
sudo -u postgres psql -d strapi -c "\dt strapi_*" | head
# strapi_administrator | table | strapi
# strapi_permission | table | strapi
# strapi_role | table | strapi
ss -lntp | grep ':1337'
# 127.0.0.1:1337 node
Strapi binds on port 1337 by default — never expose it directly; Nginx terminates TLS and proxies upstream.
What’s happening
Strapi is a Koa-based Node application with two faces: the admin panel (a Vite-built React app at /admin) and the content API. Both run inside the same Node process. Content types are defined as JSON schemas under src/api/<name>/content-types/<name>/schema.json; on startup Strapi syncs the schema to the database using Knex migrations it generates internally. The first start against an empty Postgres creates ~20 tables prefixed strapi_; subsequent schema changes add columns (additive) but require explicit data migration scripts for destructive changes.
Configuration sits in config/env/<env>/<file>.js — there is a default config and per-environment overrides. Strapi reads four secret values from env vars: APP_KEYS (an array of base64 keys for session signing), API_TOKEN_SALT, ADMIN_JWT_SECRET, JWT_SECRET. Lose any of them and existing admin sessions/API tokens invalidate. Treat them like database passwords: generate once, store in your secret manager, never commit.
Strapi serves uploaded files from /public/uploads/ by default. That works for a single instance, but the moment you scale to two nodes you need an object store. Strapi has first-party providers for S3, GCS, Cloudinary, and Azure Blob — install the one you need and switch via config/plugins.js. The admin panel does not care which provider is configured; it always shows the URL the provider returned.
The procedure
-
Install Node 20 and Postgres. Strapi 5 requires Node 18 or 20; 20 is the LTS line.
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash - sudo apt install -y nodejs postgresql postgresql-contrib nginx sudo npm install -g pm2 -
Provision the database.
DBPASS=$(openssl rand -hex 24) sudo -u postgres psql <<SQL CREATE USER strapi WITH PASSWORD '${DBPASS}'; CREATE DATABASE strapi OWNER strapi; SQL -
Create the project. Strapi’s installer is interactive; pass flags to skip the questions:
sudo useradd -m -s /bin/bash strapi sudo -u strapi -- bash -lc ' cd /home/strapi npx create-strapi-app@latest cms --quickstart=false \ --dbclient=postgres --dbhost=127.0.0.1 --dbport=5432 \ --dbname=strapi --dbusername=strapi --dbpassword='"${DBPASS}"' \ --dbssl=false --no-run --skip-cloud ' -
Generate the four secrets and write the env file.
sudo -u strapi -- bash -lc ' cat > /home/strapi/cms/.env <<EOF HOST=127.0.0.1 PORT=1337 APP_KEYS=$(openssl rand -base64 32),$(openssl rand -base64 32) API_TOKEN_SALT=$(openssl rand -base64 32) ADMIN_JWT_SECRET=$(openssl rand -base64 32) JWT_SECRET=$(openssl rand -base64 32) TRANSFER_TOKEN_SALT=$(openssl rand -base64 32) DATABASE_CLIENT=postgres DATABASE_HOST=127.0.0.1 DATABASE_PORT=5432 DATABASE_NAME=strapi DATABASE_USERNAME=strapi DATABASE_PASSWORD='"${DBPASS}"' DATABASE_SSL=false NODE_ENV=production EOF chmod 600 /home/strapi/cms/.env ' -
Build the admin and start under PM2. Strapi’s admin compiles to static assets at
dist/admin:sudo -u strapi -- bash -lc ' cd /home/strapi/cms npm run build pm2 start npm --name strapi -- run start pm2 save ' sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u strapi --hp /home/strapi -
Reverse-proxy with Nginx.
server { listen 443 ssl http2; server_name cms.example.org; ssl_certificate /etc/letsencrypt/live/cms.example.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/cms.example.org/privkey.pem; client_max_body_size 200m; location / { proxy_pass http://127.0.0.1:1337; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $remote_addr; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }Set
app.proxy = trueinconfig/server.jsso Strapi trusts theX-Forwarded-*headers. -
Switch uploads to object storage. Install the S3 provider:
cd /home/strapi/cms npm install @strapi/provider-upload-aws-s3Add to
config/plugins.js:module.exports = ({ env }) => ({ upload: { config: { provider: 'aws-s3', providerOptions: { s3Options: { region: env('AWS_REGION'), credentials: { accessKeyId: env('AWS_ACCESS_KEY_ID'), secretAccessKey: env('AWS_SECRET_ACCESS_KEY') } }, params: { Bucket: env('AWS_BUCKET') }, }, }, }, });
Common pitfalls
- The default SQLite DB Strapi creates on quickstart cannot be migrated to Postgres by dump/restore — schema is created differently. Always start with Postgres if production is Postgres.
- API tokens have an expiration and a salt that lives in env. Rotating
API_TOKEN_SALTinvalidates every token at once — useful for incident response, painful if you didn’t mean to. npm run buildmust run on every code or content-type change beforenpm run start. Forgetting it leaves the admin showing the old schema.- The admin user table (
strapi_administrator) lives in the same DB as the content; do not let public API roles include any of those tables. - Strapi’s lifecycle hooks (
afterCreate,beforeUpdate) run synchronously inside the request — slow webhook calls there block the editor’s Save button.
For teams that need a Node-based headless CMS in production, Stack Harbor operates the Strapi stack — Postgres backed up and PITR-capable, secrets in a vault, PM2 reload patterns that don’t drop admin sessions, S3 lifecycle on the uploads bucket — so the content team only sees the admin. That operating model lives under managed operations, with related Directus and Ghost notes alongside.