How to Set Up Node.js with PM2
How to Set Up Node.js
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt install nodejs -y
# CentOS/AlmaLinux
curl -fsSL https://rpm.nodesource.com/setup_lts.x | bash -
dnf install nodejs -y
# Verify
node --version
npm --version
Running a Node.js App in Production with PM2
# Install PM2 globally
npm install -g pm2
# Start your application
pm2 start app.js --name "my-app"
# Set PM2 to start on boot
pm2 startup
pm2 save
# Other useful commands
pm2 list # List running apps
pm2 logs my-app # View logs
pm2 restart my-app
pm2 stop my-app