I choose ubuntu here. No need to change default settings. Skip to step 6
connect to ec2 instance on terminal Install nodejs
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Install git
sudo apt-get install git
Redirect port 80 to 8081
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8081
Run server on ec2
cd apis
npm install
node app
Keep App running using pm2
sudo npm install pm2 -g
pm2 start app.js
Automatically run PM2 when the server restarts
sudo pm2 startup