amp-web-push-widget button.amp-subscribe { display: inline-flex; align-items: center; border-radius: 5px; border: 0; box-sizing: border-box; margin: 0; padding: 10px 15px; cursor: pointer; outline: none; font-size: 15px; font-weight: 500; background: #4A90E2; margin-top: 7px; color: white; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.5); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .web-stories-singleton.alignleft,.web-stories-singleton.alignnone,.web-stories-singleton.alignright{display:block;width:100%}.web-stories-singleton.aligncenter{text-align:initial}.web-stories-singleton .wp-block-embed__wrapper{position:relative}.web-stories-singleton.alignleft .wp-block-embed__wrapper{margin-right:auto}.web-stories-singleton.alignright .wp-block-embed__wrapper{margin-left:auto}.web-stories-singleton.alignnone .wp-block-embed__wrapper{max-width:var(--width)}.web-stories-singleton.aligncenter .wp-block-embed__wrapper{margin-left:auto;margin-right:auto;max-width:var(--width)}.web-stories-singleton-poster{aspect-ratio:var(--aspect-ratio);border-radius:8px;cursor:pointer;overflow:hidden;position:relative}.web-stories-singleton-poster a{aspect-ratio:var(--aspect-ratio);display:block;margin:0}.web-stories-singleton-poster .web-stories-singleton-poster-placeholder{box-sizing:border-box}.web-stories-singleton-poster .web-stories-singleton-poster-placeholder a,.web-stories-singleton-poster .web-stories-singleton-poster-placeholder span{border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-wrap:normal;word-break:normal}.web-stories-singleton-poster img{box-sizing:border-box;height:100%;object-fit:cover;position:absolute;width:100%}.web-stories-singleton-poster:after{background:linear-gradient(180deg,hsla(0,0%,100%,0),rgba(0,0,0,.8));content:"";display:block;height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.web-stories-singleton .web-stories-singleton-overlay{bottom:0;color:var(--ws-overlay-text-color);line-height:var(--ws-overlay-text-lh);padding:10px;position:absolute;z-index:1}.web-stories-embed.alignleft,.web-stories-embed.alignnone,.web-stories-embed.alignright{display:block;width:100%}.web-stories-embed.aligncenter{text-align:initial}.web-stories-embed .wp-block-embed__wrapper{position:relative}.web-stories-embed.alignleft .wp-block-embed__wrapper{margin-right:auto}.web-stories-embed.alignright .wp-block-embed__wrapper{margin-left:auto}.web-stories-embed.alignnone .wp-block-embed__wrapper{max-width:var(--width)}.web-stories-embed.aligncenter .wp-block-embed__wrapper{margin-left:auto;margin-right:auto;max-width:var(--width)}.web-stories-embed:not(.web-stories-embed-amp) .wp-block-embed__wrapper{aspect-ratio:var(--aspect-ratio)}.web-stories-embed:not(.web-stories-embed-amp) .wp-block-embed__wrapper amp-story-player{bottom:0;height:100%;left:0;position:absolute;right:0;top:0;width:100%}.block-editor-block-inspector .web-stories-embed-poster-remove{margin-left:12px} .amp-logo amp-img{width:190px} .amp-menu input{display:none;}.amp-menu li.menu-item-has-children ul{display:none;}.amp-menu li{position:relative;display:block;}.amp-menu > li a{display:block;} /* Inline styles */ div.acss138d7{clear:both;}div.acss5dc76{--relposth-columns:3;--relposth-columns_m:2;--relposth-columns_t:3;}div.acss3c158{aspect-ratio:1/1;background:transparent url(https://newsondate.com/wp-content/uploads/2025/07/Oppo-Reno-14-Pro-Launch-150x150.png) no-repeat scroll 0% 0%;height:150px;max-width:150px;}div.acss6bdea{color:#333333;font-family:Arial;font-size:12px;height:75px;}div.acss54bd9{aspect-ratio:1/1;background:transparent url(https://newsondate.com/wp-content/uploads/2025/06/AI-at-Salesforce-150x150.png) no-repeat scroll 0% 0%;height:150px;max-width:150px;}div.acssda8eb{aspect-ratio:1/1;background:transparent url(https://newsondate.com/wp-content/uploads/2025/06/HPE-Juniper-Deal-Approved-150x150.png) no-repeat scroll 0% 0%;height:150px;max-width:150px;} .icon-widgets:before {content: "\e1bd";}.icon-search:before {content: "\e8b6";}.icon-shopping-cart:after {content: "\e8cc";}
In this blog we will learn how to Deploy Nodejs and MongoDB on AWS EC2 instance. In today’s fast-paced digital world, building scalable and reliable web applications is crucial. Combining Nodejs for backend development and MongoDB for database management is a powerful duo. But how do you deploy them on a robust cloud platform like Amazon AWS EC2? This guide will walk you through the process step-by-step, ensuring your app is up and running in no time!
Before diving into deployment, you need an AWS EC2 instance. Here’s how to set it up:
Once your instance is ready, it’s time to install Nodejs.
To install Nodejs on your EC2 instance, follow these steps:
sudo yum update -y
to ensure all packages are up to date.node -v
and npm with npm -v
.curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs
Now that your environment is set up, let’s deploy your Nodejs app:
npm install
to install dependencies.node app.js
or use a process manager like PM2 for better reliability:sudo npm install -g pm2
pm2 start app.js
To integrate MongoDB with your Nodejs app, follow these steps:
Create file with Command
vi /etc/yum.repos.d/mongodb-org-8.0.repo
[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2023/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-8.0.asc
2. Install MongoDB:
sudo yum install -y mongodb-org
3. Start MongoDB Service:
sudo systemctl start mongod
sudo systemctl enable mongod
4.Connect Nodejs to MongoDB: Update your app’s database connection string to point to your MongoDB instance.
Using GitHub for deployment ensures seamless updates and collaboration. Here’s how to deploy your Nodejs app:
Install Git: Install Git on your EC2 instance:
sudo yum install git -y
Clone Your Repository: Navigate to your desired directory and clone your GitHub repository:
git clone https://github.com/your-username/your-repo.git
cd your-repo
Install Dependencies: Run npm install
to install all dependencies listed in your package.json
file:
npm install
Run Your App: Start your app using node app.js
or use PM2 for better reliability
sudo npm install -g pm2
pm2 start app.js
Your Nodejs app is now live on AWS EC2!
Security is critical when deploying applications. Here are some best practices:
.env
files.Deploy Nodejs and MongoDB on AWS EC2 might seem complex, but this guide simplifies the process. By leveraging GitHub for code deployment, you’ve ensured a streamlined workflow for future updates. Whether you’re building a startup app or scaling an enterprise solution, AWS provides the infrastructure to support your growth. Now, your app is ready to handle real-world traffic and scale effortlessly.
Overview of the Thomas Partey Rape Charges In a major development, Thomas Partey, the former…
Vidit Gujrathi LiverDoc Feud: Twitter Clash Over Doctor’s Day Post Sparks Online Debate How the…
Salman Khan Galwan Valley Poster Tease Sends Fans into a Frenzy. Bollywood megastar Salman Khan…
The Joey Chestnut Hot Dog Eating Contest comeback at Coney Island on the Fourth of…
Texas Flooding Emergency: Catastrophic Rainfall Sparks Deadly Flash Floods Across Central Texas The Texas flooding…
The Jamie Smith Harry Brook partnership has become a major highlight of the ongoing second…