Deploy a Node.js app with PM2
Install Node.js, run your API with PM2 and configure the auto restart.
Ready to start your service? Check offers and order online.
View offers and orderObjective
Host an API or a Node.js bot in production with automatic restart thanks to PM2.
Installation Node.js and PM2
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs
npm install -g pm2Deploy application
- Cloner or uploader
Your project in
/var/www/monapp, thennpm ci --production. - Start with PM2
pm2 start src/index.js --name monapp - Reverse proxy Nginx
Proxy to
http://127.0.0.1:3000(see guide Nginx). - Reboot persistence
pm2 startupthenpm2 save
Logs
pm2 logs monapp and pm2 monit to monitor CPU/RAM.