This repository is used for deploying a Node.js application on a Linux EC2 server using PM2 for process management.
- A Linux EC2 instance
- Port 80 (or 3000) open in your security group
- Basic knowledge of Linux terminal
ssh ec2-user@<your-ec2-public-ip>sudo yum install git -ysudo dnf install -y nodejsgit clone git@github.com:gou8m/sample-nodejs-application.git
cd sample-nodejs-applicationnpm installnpm start
# App will be available at http://<your-ec2-ip>npm install -g pm2pm2 start index.js --name node-apppm2 list # View all apps
pm2 logs node-app # View logs
pm2 restart node-app # Restart app
pm2 stop node-app # Stop app
pm2 delete node-app # Remove app
pm2 save # Save current process list
pm2 startup # Enable PM2 on boothttp://<your-ec2-public-ip>