Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Node.js Application Deployment Guide

This repository is used for deploying a Node.js application on a Linux EC2 server using PM2 for process management.


🧰 Tools & Technologies Used


📦 Prerequisites

  • A Linux EC2 instance
  • Port 80 (or 3000) open in your security group
  • Basic knowledge of Linux terminal

🛠️ Deployment Steps

1️⃣ Connect to EC2 Instance

ssh ec2-user@<your-ec2-public-ip>

2️⃣ Install Git

sudo yum install git -y

3️⃣ Install Node.js and npm

sudo dnf install -y nodejs

4️⃣ Clone the Project Repository

git clone git@github.com:gou8m/sample-nodejs-application.git
cd sample-nodejs-application

5️⃣ Install Dependencies from package.json

npm install

6️⃣ Start the App (interactive mode)

npm start
# App will be available at http://<your-ec2-ip>

7️⃣ Issue: App stops on logout or CTRL+C

To fix that, use PM2 (a process manager)

8️⃣ Install PM2 Globally

npm install -g pm2

9️⃣ Run App with PM2

pm2 start index.js --name node-app

✅ PM2 ensures your app:

- Runs continuously

- Restarts on crashes

- Provides monitoring and logs

🔄 Optional PM2 Commands

pm2 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 boot

🌐 Access the App

Once the app is running via PM2 on your EC2 instance, access it in your browser:

http://<your-ec2-public-ip>

About

Deployment of NodeJS Application

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages