This guide will help you test the project locally and deploy it on AWS EC2
Welcome to our step-by-step guide on deploying the Deploy Node Js AWS project! Whether you're a beginner or someone unfamiliar with technical jargon, I've crafted this guide to make the process easy to follow.
Whenever you have start any project ,Please make sure your project is running successfully in locally .
Testing the Project Locally
1. Clone the Project
Open your terminal or command prompt.
Run:
git clone
https://github.com/sprasadpujari/DeployNodeJs_AWS.git
2. Download and Install Node.js
Head to Node.js Download.
Download and install Node.js.
3. Create a .env File
- Run:
touch .env
4. Set Up Environment Variables
Set Up Environment Variables Now, let's configure some basic settings. Create a file named .env in the project's main folder and add the following lines: Create a .env file in the project root and add the following variables:
DOMAIN=""
PORT=3000
STATIC_DIR="./client"
PUBLISHABLE_KEY=""
SECRET_KEY=""
5. Initialize and Start the Project
Run:
npm install
npm run start
Now lets start Set Up an AWS EC2 Instance
6. Create IAM User (if not done)
- In my previous blog, I provided detailed instructions on how to create IAM users in AWS. Kindly follow the outlined steps for seamless implementation.
https://hashnode.com/post/clplgbv7u00010algfkdnhx70
Once an IAM (Identity and Access Management) user is successfully created in AWS.
7. Sign In as IAM User
Enter IAM username and password.
Click "Sign In."
Review the console region.
8. Create EC2 Instance (if not done)
- In my previous blog, I have already covered the steps for creating an EC2 instance. Please follow the provided instructions for a smooth and successful implementation.
https://hashnode.com/post/clnumbs4u000208ifg51u1xm4
Once an EC2 instance is successfully created in AWS following the above
steps.
9. Connect to Instance Using SSH
Run
ssh -i instance.pem ubuntu@<IP_ADDRESS>
10. Configure Ubuntu on Remote VM
Configure Ubuntu on Remote VM Update outdated packages and dependencies:
run below command
sudo apt update
Check git version if it is already installed ,and install node Js
Check Node version ,and install npm
11. Clone Project onto AWS Instance
12. Set Up Environment Variables on Remote VM
Create a .env file and add the variables.
13.Initialize and Start Project on Remote VM
14. Adjust Inbound Rules
Don't forget to adjust the inbound rules in your EC2's security group to allow traffic on the specified port. our port is 3000
15. Congratulations!
Congratulations! Node Js project is now deployed on AWS. π
Copy your instance public ip ,and port 3000
This guide should help you navigate through the technicalities and successfully deploy your Node.js project on AWS. If you encounter any difficulties, feel free to reach out for assistance. Happy coding! π
If you found this post helpful, kindly consider following and hitting the like button below to express your support! π
Thank you for taking the time to read! π
Warm regards,
Sprasad π»β¨