Prerequisites & System Requirements
Ensure your development workstation or staging server fulfills the following prerequisites before initiating commands:
Target System Architecture Diagram
Interactive Execution Checklist
Step-by-Step Implementation Guide
Initial Infrastructure & Environment Setup
Provision core Linux environment variables, firewall rules, and Node.js runtime dependencies.
Execute Command Terminal:
sudo apt update && sudo apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs nginx git docker.ioExpected Terminal Output:
✔ node v20.11.0 installed ✔ nginx v1.18.0 (Ubuntu) active ✔ docker v24.0.5 running
Permission denied error during apt-get update. — Ensure you are running commands with 'sudo' or logged in as root user.
Configure Environment Secrets & Variables
Create a isolated .env file to store MongoDB connection URI, JWT secrets, and API keys securely.
Execute Command Terminal:
cat << 'EOF' > .env
NODE_ENV=production
PORT=8000
MONGO_URI=mongodb+srv://admin:secret@cluster0.mongodb.net/production
JWT_SECRET=super_secure_enterprise_secret_key_99
EOFExpected Terminal Output:
✔ .env file created with mode 0600 (owner read/write only)
JWT Secret missing during app bootstrap. — Verify .env path is loaded at app entry point using dotenv.config().
Deploy PM2 Process Manager & Reverse Proxy
Set up PM2 cluster mode for zero-downtime reloads and link NGINX as an SSL reverse proxy.
Execute Command Terminal:
sudo npm install -g pm2
pm2 start server.js -i max --name 'inteliny-api'
pm2 save && pm2 startupExpected Terminal Output:
[PM2] App [inteliny-api] launched in cluster mode (4 workers) [PM2] Freeze a system startup script
Process restarts repeatedly (Crash Loop). — Check application log files with 'pm2 logs inteliny-api --err'.
Production Best Practices & Hardening
Security Hardening
Disable root SSH access, enforce key-based auth, and enable UFW firewall on ports 80/443.
Memory Management
Set Node.js max-old-space-size to 80% of total RAM to avoid Linux OOM-killer crashes.
Frequently Asked Questions
Yes, all NGINX, Docker, and PM2 deployment steps can be packaged into Infrastructure as Code (IaC) playbooks.
Need Help Implementing This?
Partner with Inteliny's principal architects to audit your stack, automate CI/CD, and accelerate deployment.