; ============================================================================ ; systemd alternative to PM2 — use ONE of the two, not both. ; ; sudo cp deploy/support-portal.service /etc/systemd/system/ ; sudo systemctl daemon-reload ; sudo systemctl enable --now support-portal ; sudo systemctl status support-portal ; journalctl -u support-portal -f ; ; Adjust User=, WorkingDirectory= and the node path for your VPS. ; ============================================================================ [Unit] Description=Universal Support Portal (Next.js) Documentation=file:///var/www/support-portal/DEPLOY.md After=network.target mariadb.service mysqld.service Wants=mariadb.service [Service] Type=simple User=support Group=support WorkingDirectory=/var/www/support-portal Environment=NODE_ENV=production Environment=HOSTNAME=127.0.0.1 Environment=PORT=3000 EnvironmentFile=/var/www/support-portal/.env ; `which node` on the VPS — with nvm it is /home//.nvm/versions/node/vX/bin/node ExecStart=/usr/bin/node node_modules/next/dist/bin/next start Restart=always RestartSec=5 KillSignal=SIGINT TimeoutStopSec=30 ; hardening NoNewPrivileges=true PrivateTmp=true ProtectSystem=full ProtectHome=read-only ReadWritePaths=/var/www/support-portal/.next StandardOutput=journal StandardError=journal SyslogIdentifier=support-portal [Install] WantedBy=multi-user.target