Server Deployment (Production)
A complete, beginner-friendly path from a fresh Ubuntu VPS to a live marketplace. Commands are repository-verified; values in CAPS are placeholders for your own.
On this page
Overview & prerequisites
SaleX is a Node.js application. Production needs: a Linux server (2 vCPU / 4 GB RAM recommended), PostgreSQL (managed service or on-server), Node.js 20+, and an Nginx (or Caddy) front for HTTPS. You cannot use shared PHP hosting — see System Requirements.
Where things happen: server terminal for everything below; hosting dashboards only for DNS records and (if used) the managed database panel.
Prepare the server
SSH in (ssh root@YOUR_SERVER_IP) and install the runtime:
# Update packages
apt update && apt upgrade -y
# Node.js 22 LTS via NodeSource
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt install -y nodejs
# Nginx reverse proxy + git (for pulling the code)
apt install -y nginx git
# Verify
node -v && npm -v✓ Success: Node prints v22.x. If you self-host PostgreSQL, install postgresql the same way and create the database as in Database & Storage → Self-hosted PostgreSQL.
Upload SaleX & install
Choose one:
# Option A — copy the extracted package to the server (from YOUR machine)
scp -r ./salex root@YOUR_SERVER_IP:/var/www/salex
# Option B — if you keep the project in a private Git repo
git clone https://github.com/YOU/YOUR_REPO.git /var/www/salexThen on the server:
cd /var/www/salex
npm install # production dependencies only: npm ci --omit=dev also works
npm run db:generate # generate the Prisma clientnode_modules, .next, and .env — dependencies install fresh, the build is created on the server, and .env is created in the next step.Production environment
nano .envMinimum production values:
DATABASE_URL="postgresql://USER:STRONG_PASSWORD@DB_HOST:5432/salex"
DIRECT_URL="postgresql://USER:STRONG_PASSWORD@DB_HOST:5432/salex"
APP_URL="https://YOUR_DOMAIN.com"
NEXT_PUBLIC_SITE_URL="https://YOUR_DOMAIN.com"
AUTH_SECRET="GENERATE with: openssl rand -base64 32"
NODE_ENV="production"
# + your SMTP and payment provider variables (see Environment Configuration)APP_URL must be your real HTTPS domain — localhost values break emails, webhooks, and checkout redirects. Never reuse your local AUTH_SECRET; generate a fresh one per environment.Production database
Point DATABASE_URL/DIRECT_URL at the production database (managed service recommended for backups), then apply the schema:
npm run db:deployIf this is a brand-new database, seed it once:
SEED_SUPER_ADMIN_EMAIL="you@YOUR_DOMAIN.com" \
SEED_SUPER_ADMIN_PASSWORD_HASH='PRECOMPUTED_BCRYPT_HASH' \
npm run db:seeddb:migrate, db:seed (twice), or any reset command against a production database with real orders. Migrate-then-deploy is developer workflow; buyers use db:deploy only.Build & run
npm run build✓ Success: “Compiled successfully” and route listing. Build errors at this point mean environment variables are missing — check the error text against the Environment page.
Keep it running with pm2:
npm install -g pm2
pm2 start npm --name salex -- start
pm2 save
pm2 startup # run the command it prints — survives server reboots✓ Success: pm2 status shows “online”. The app now answers on port 3000.
Reverse proxy & HTTPS
Create /etc/nginx/sites-available/salex:
server {
listen 80;
server_name YOUR_DOMAIN.com www.YOUR_DOMAIN.com;
client_max_body_size 20m; # allow product image uploads
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_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}Enable it and add HTTPS with free Let's Encrypt certificates:
ln -s /etc/nginx/sites-available/salex /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
apt install -y certbot python3-certbot-nginx
certbot --nginx -d YOUR_DOMAIN.com -d www.YOUR_DOMAIN.com✓ Success: https://YOUR_DOMAIN.com loads the storefront with a padlock. DNS: create an “A” record pointing your domain at YOUR_SERVER_IP (in your domain registrar's dashboard — the one dashboard step).
Updating safely
- Back up first (database + storage/ — see Security & Backups).
- Upload/clone the new version over the project (or git pull).
- Run in order:
npm install→npm run db:generate→npm run db:deploy→npm run build→pm2 restart salex. - Smoke-test: homepage, product page, login, one test checkout.