Local machine → GitHub → AWS EC2 → Live on the internet
Local machine → GitHub → AWS EC2 → Live on the internet
Local machine → GitHub → AWS EC2 → Live on the internet
npm install
npm start
npm install
npm start
npm install
npm start
"scripts": { "start": "node index.js"
}
"scripts": { "start": "node index.js"
}
"scripts": { "start": "node index.js"
}
git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main
git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main
git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main
# .gitignore
node_modules/
.env
# .gitignore
node_modules/
.env
# .gitignore
node_modules/
.env
chmod 400 your-key-file.pem
ssh -i your-key-file.pem ubuntu@your-public-ip
chmod 400 your-key-file.pem
ssh -i your-key-file.pem ubuntu@your-public-ip
chmod 400 your-key-file.pem
ssh -i your-key-file.pem ubuntu@your-public-ip
sudo apt update && sudo apt upgrade -y
sudo apt update && sudo apt upgrade -y
sudo apt update && sudo apt upgrade -y
sudo apt install -y nodejs npm
sudo apt install -y nodejs npm
sudo apt install -y nodejs npm
node -v
npm -v
node -v
npm -v
node -v
npm -v
git clone https://github.com/yourusername/your-repo.git
cd your-repo
git clone https://github.com/yourusername/your-repo.git
cd your-repo
git clone https://github.com/yourusername/your-repo.git
cd your-repo
npm install
npm install
npm install
PORT=3000
DATABASE_URL=your_database_url
API_KEY=your_api_key
PORT=3000
DATABASE_URL=your_database_url
API_KEY=your_api_key
PORT=3000
DATABASE_URL=your_database_url
API_KEY=your_api_key
http://your-public-ip:3000
http://your-public-ip:3000
http://your-public-ip:3000
sudo npm install -g pm2
pm2 start index.js
pm2 startup
pm2 save
sudo npm install -g pm2
pm2 start index.js
pm2 startup
pm2 save
sudo npm install -g pm2
pm2 start index.js
pm2 startup
pm2 save
✅ App tested locally with npm start
✅ .env added to .gitignore
✅ Code pushed to GitHub
✅ EC2 instance launched (Ubuntu, t2.micro)
✅ Key pair downloaded safely
✅ SSH into server
✅ Server updated (apt update && upgrade)
✅ Node.js and npm installed
✅ Repo cloned and npm install run
✅ .env file created manually on server
✅ npm start — app is running on server
✅ Security group inbound rules configured (ports 22, 80, 3000)
✅ App visible at public-ip:3000
✅ pm2 set up to keep it running
✅ App tested locally with npm start
✅ .env added to .gitignore
✅ Code pushed to GitHub
✅ EC2 instance launched (Ubuntu, t2.micro)
✅ Key pair downloaded safely
✅ SSH into server
✅ Server updated (apt update && upgrade)
✅ Node.js and npm installed
✅ Repo cloned and npm install run
✅ .env file created manually on server
✅ npm start — app is running on server
✅ Security group inbound rules configured (ports 22, 80, 3000)
✅ App visible at public-ip:3000
✅ pm2 set up to keep it running
✅ App tested locally with npm start
✅ .env added to .gitignore
✅ Code pushed to GitHub
✅ EC2 instance launched (Ubuntu, t2.micro)
✅ Key pair downloaded safely
✅ SSH into server
✅ Server updated (apt update && upgrade)
✅ Node.js and npm installed
✅ Repo cloned and npm install run
✅ .env file created manually on server
✅ npm start — app is running on server
✅ Security group inbound rules configured (ports 22, 80, 3000)
✅ App visible at public-ip:3000
✅ pm2 set up to keep it running - You have a Node.js/Express app that runs locally with npm start
- Your project is (or will be) on GitHub
- You have an AWS account (free tier works perfectly for this) - Log into AWS Console
- Search for EC2 and click Launch Instance
- Fill in the details: Name: give it something meaningful like my-first-app AMI: choose Ubuntu Server 22.04 LTS (free tier eligible) Instance type: t2.micro (free tier — perfect for this)
- Name: give it something meaningful like my-first-app
- AMI: choose Ubuntu Server 22.04 LTS (free tier eligible)
- Instance type: t2.micro (free tier — perfect for this)
- Key pair: Create a new key pair, name it, and download the .pem file. Don't lose this — it's the only way to SSH into your server.
- Leave everything else as default for now and click Launch Instance - Name: give it something meaningful like my-first-app
- AMI: choose Ubuntu Server 22.04 LTS (free tier eligible)
- Instance type: t2.micro (free tier — perfect for this) - Go to your EC2 Dashboard → click your instance
- Go to the Security tab → click the Security Group link
- Click Edit Inbound Rules and add: - Click Save rules