curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
nvm install 24

git clone https://github.com/thienluhoan/000006-EC2.git
cd 000006-EC2
npm init

npm install pm2 -g && npm install

pm2 start app.js

Enter touch .env && nano .env to enter environmental variables
Continue using nano to access the .env file, then enter the following content to set up the connection to the database.
DB_HOST='YOUR-RDS-ENDPOINT'
DB_NAME='fcaj'
DB_USER='admin'
DB_PASS='Aa12345#'

npm start
pm2 status in PM2 is used to display the current status of all applications being managed by PM2. When you run this command, you’ll receive an overview of each application, including details like their state (running, stopped, etc.), memory usage, CPU usage, and the number of restarts. This helps in monitoring the performance and health of your Node.js applications effectively.


pm2 startup to configure PM2 to automatically restart applications when the server reboots.
We continue excute the following command:sudo env PATH=$PATH:/home/ec2-user/.nvm/versions/node/v24.13.1/bin /home/ec2-user/.nvm/versions/node/v24.13.1/lib/node_modules/pm2/bin/pm2 startup systemd -u ec2-user --hp /home/ec2-user

pm2 save to save your configurations
