Easily Deploy Full Stack Node.js Apps on AWS EC2 | Step-by-Step Tutorial
Вставка
- Опубліковано 7 чер 2024
- Learn to deploy a Node.js or Bun app connected to a PostgreSQL or MySQL database on AWS EC2 Ubuntu Instance. This video covers the setup of a continuous background run for the app using SystemD, and setting up a reverse proxy with Caddy for handling HTTP requests and SSL certificates. Finally, I show how to configure a custom domain with AWS Route 53 for easy access and SSL security.
Chapters:
0:00 Setup EC2
3:10 Connect using SSH
4:55 Update Ubuntu
6:06 Install Node/bun
7:26 rsync code to server
10:25 Run Node.js App
12:40 Modify Security Group
14:18 Install Postgres/MySQL
17:47 systemd
22:56 Caddy server/reverse proxy
25:35 DNS & SSL
28:09 Summary
Help support me make more videos: ko-fi.com/meechward
🔗 Code Snippets: www.sammeechward.com/deployin...
🔗Moar Links
My Website: www.sammeechward.com
Instagram: / meech_ward
TikTok: / meech.s.ward
X: / meech_ward
Threads: www.threads.net/@meech_ward
Github: github.com/orgs/meech-ward - Наука та технологія
Finally a video from A to Z... Most video of AWS tutorial I found start from Y to Z...
true!!
Stumbled upon the video, and watched the whole thing - at normal speed and rewinding along the way. Great material
Your videos are always straightforward and I absolutely love them 🥰
Ive been waiting all my life to understand what my boss had me do my computer via Google cloud run 😅. This is a hrll of a revision. thanks man.
Your video was very well done. I was able to deploy a nodejs webapp on my first attempt. Your 30 minute video took me about 7 hours to complete and I was filled with dread when you said at the end that you had a short 7 minute video explaining how to buy a domain name. I knew that was gonna take me 30 mins to an hour. But time is not an issue, understanding is, when it's your first time. I invested the time to thoroughly understand your instructions and deploy the app. It went off well and my app is up now and ready to be tested by users. Well done!!!!
this is exactly what I was looking for. After taking notes I am excited to practice this many times to ensure foundational knowledge. Awesome stuff!!
Woahhh...Woahhhh. What a great tutorial sir!. I was thinking to learn how to host a server in cloud and what is ssh what is reverse proxy how to map domain name to our server...like man i got all the answers in a single 30min video. Thank you so much for producing these high quality videos and keep on doing em! Hats-off.
Man, this is the greatest tutorial video that I've ever seen!
Thank you 🤗
You always deliver an amazing UA-cam tutorial for the viewers! Your explanations are always spot on! Thank you so much!!! :)
Thank yo so much for this tutorial. This is the only working tutorial in the internet and explains everything so good and it only takes 28 minutes
this was incredibly helpful, got my first custom domain web app running!
Your way you explain things makes you one of the best tutor i know, Thank you so much
Man your videos are amazing and really clear. you gained a subscriber. Thanks
Thanks so much, your way of teaching makes things simpler. Waiting for more videos 💫
Got my first "Full Stack" data analysis app up with this video. You helped connect a lot of dots that were not connected by amazons documentation. Thanks!
Glad it helped 🤗
Fantastic walkthrough!
Fantastic comment!
I've been looking for straight forward instructions for months. Thanks to you My site is hosted. Still need to figure out how to install and configure a MongDB database
Brilliant tutorial !!
You are incredible kind sir. Thank you for this
Super helpful, Thanks!
Thanks, this helped me a lot!!
Great plugins thanks!
This was really great.
the best tutorial, thank you so much
Really nice explained
thank you
Fantastic the way you explained. And i request you make a tutorial on pm2 load balancer etc... thanks
You're amazing. Thanks alot !!
This is a really great video.
Insane value!!
broooo this video is so solid
awesome !!! love this content
top notch content Sam! Would you care to explain what you meant by 'I have a migration system on my app". Why did you have to run npm run migrate? Thanks!
Thanks bro a lot for this tutorial
Great tutorial! I did something similar using Linode, but used nginx instead of Caddy. Caddy seem like a simpler choice with the automated ssl.
I only recently started using it, but it's been awesome and I trust the community behind it
banging video mate ! Do you mind if I ask what software you use to edit your videos ? The transitions and zoom effects are top class
I use a few different pieces of software, but my main video editing is done in Camtasia. It's pretty easy to use and all the basics are covered in their intro 45 minute video: ua-cam.com/video/AE1Hfy-yw4s/v-deo.html
really amazing tutorial
Awesome job! thank you. What about MongoDB and nginx, I hope you explain that someday. Another question, please: How can I get the client's IP (remote ip)?
Thank you!
Fantastic video
Can you do a follow-up video, just covering changes required if using Bun instead of Node Js?
Dope!!!!!
Really helpful video. Would be nice if you could create a video about how to automate all these stuff with github actions. Thanks
absolute legend
can anyone explain to me how the server file and the react app both run? I am having a lot of troulble starting my vite app in the front end directory and the server from the systemD command?
Thanks!
quick question can we not add our git credentials to the server and then use them to pull changes and deploy from the server or if that is not a standard practice ?
Can you please make video setting up Nginx to Nextjs? Definitely an insightful video, thank you for introducing me to caddy. 😊
Thank you !!!
Great video!
Can you also tell us how to do continuous delivery?
Have you put the frontend requests to localhost or a specific IP?
thank you so much.
this might be a dumb question. instead of copying your files from the local machine to the remote machine. you can install git on ec2 and pull from repo ?
Yeah but it's too much hassle just for this video. You will have to create and delete the repo
Yes, you can
I imagine that there will be some files that won't be located on the repo you may want to copy over. For example .env files
@snakefinn but he didn't copy over the .env files using rsync either lol.
imagine u lose ur git account
if i already have a .env on my project directory to be consumed by my node app I still have to do the env variables part for systemd ?
Fantastic
Hi I'm new to AWS cloud computing, could you explain why you used EC2 rather than AWS amplify in this instance :)
thank you for the vid, would you explain how to protect ec2 against something like ddos? i’d like to try ec2 but in fear of overcharging by aws
ddos wouldn't increase the cost of a single ec2 instance like this. It would grind your app to a halt, but no additional costs. I'm pretty sure all services, including ec2, are protected from basic ddos attacks with aws shield aws.amazon.com/shield/
Any alternatives o rysnc? Does not work on git bash
great video thanks. Can you create a video about doing same with Terraform please?
Thank you. That's a bit more of a challenge because terraform isn't really used for single instance configuration. You would end up using something like packer to create an ec2 image of the node app, then use terraform to create a new instance based on the image. Terraform is used for immutable infrastructure, which this is not. However, I do have a series of videos on how to use terraform and packer for this kind of stuff, but you'd end up with many ec2 instances instead of just one.
Thanks for the video! Can you make a video on how to handle new version of the app without downtime?
With one server, you wold always experience some amount of downtime. It could be minimal though, just the amount of time it takes to restart caddy, so a few milliseconds. The only way I know of to get absolute 0 downtime is to use multiple ec2 instances with a load balancer, which is much more complex
at 9:56 how do you go to my app git(main)
Awesome job! Would be great to see how to move from this infrastructure to one more scalable, with a dedicated RDS instance, a load balancer and maybe different ec2 instances for different microservices, maybe using terraform. But as you said this is foundational and it's very well done!
How can i setup the database so that it is in a private subnet and can be accessed only by the ec2 instances within my vpc
Hi Sam, can you make one video for the Serverless approach??
Can u please make video on automatic things?
Would be appreciated 🙏
Wow this is good. I have questions and suggestion.
Does that systemd replaces the use of pm2? Why didn't you use pm2
Suggestion: Moving forward with this with setting up basic testing and CI CD.
Good question and suggestion.
I am currently using pm2...For CI CD I found this ua-cam.com/video/fkzpywlJcMA/v-deo.html@@KratosCY
I really would like a similar tutorial that uses Docker on ec2
hey can you explain more about migrate postgres sql db into ec2 how to create migrate.ts file and other things
are these all free within free tier usage?
12:32 i clicked the "open address" from AWS console rather than copying the address so it was opening the app in https not http and i was unable to access it. I was stuck on this for a day
Great work!
but isnt pm2 a better practice instead of systemd ?
latter in the video i understood the mindset of you teaching the basics first so it makes sense, thank you!
Can I host many websites on single EC2 instance
Can you share the codebase? Would you like to do some practice? I can't find it on your Github
hey i am unable to copy my folder from windows to ubuntu. I got the public key and invalid hostname error. Any solution?
I have an App.js running on port 3000 and a Server.js (Backend) running on port 5000. How would this work?
+1
I am assuming that you are having your app.js using server.js files , so that eventually it is able to connect to it how it connect on local computer , because you could see that it is still now being running on local host 3000 so that would be able to access the 5000 port server running on it .
Can u create SSR on aws with React
Bro how much it could cost for storing Mern stack
great
Thanks for watching! I'm glad you enjoyed it.
👍
OCD speed?
Wouldn’t it be easier to just dockerize the application and use docker compose on the ec2 instance by using ansible?
Feel it would be much cleaner to build images and bundle them into a compose file 🤔
Docker makes some things easier and some things more complex. My issue with docker is that there's a learning curve in the beginning, in order to use docker, you have to learn docker. And in the end, you still have to understand how VMs work. So I avoid using docker or teaching with docker, unless it's absolutely necessary.
is it okey if I add source code via github ?
Hello , can you point me to the code for this tutorial?
It asks for password if i do chmod 400 so what password should i write there for that instance
Note on 19:18 that if you installed Node.js differently, like via the NVM Node Version Manager, you have to set different ExecStart path in the .service file - or else you'll receive an error "Active: failed [...] Process: .... ExecStart=/usr/bin/node index.js (code=exited, status=203/EXEC)" when doing "sudo systemctl status myapp.service".
what changes are to be made?
can you migrate to t2.small later on ?
Yes, you just have to stop the instance first.
Don't mind me brother, you look something like Eliot Anderson
😆😆Dude u actual have a DRIZZLE folder are you in the movement too🤣🤣🤣woow
Do you have any courses that I can buy? Please take my money
Couldn't this be done inside nginx?
Did you watch the video? Honest question. He addresses that he normally would use Nginx.
We use AWS to insure more food shortages and plandemics.
Please show the same detailed video, but deploy the finished project in Amplify + Lambda
Honestly, I avoid amplify at all costs. My recommendation is to try SST.dev
Yall never heard of git and docker ?
😂
this is far from easily, why are you not using SST
I love SST, when I want a serverless environment
Thanks!