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
  • Наука та технологія

КОМЕНТАРІ • 126

  • @nasrularif9570
    @nasrularif9570 3 місяці тому +42

    Finally a video from A to Z... Most video of AWS tutorial I found start from Y to Z...

  • @and_ppv
    @and_ppv 4 місяці тому +19

    Stumbled upon the video, and watched the whole thing - at normal speed and rewinding along the way. Great material

  • @astronautonmars
    @astronautonmars 4 місяці тому +2

    Your videos are always straightforward and I absolutely love them 🥰

  • @ScriptCodec
    @ScriptCodec 4 місяці тому +3

    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.

  • @TimothyHuey
    @TimothyHuey 2 місяці тому +7

    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!!!!

  • @cashamigos
    @cashamigos 3 місяці тому

    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!!

  • @devaa7076
    @devaa7076 4 місяці тому +3

    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.

  • @tuscala
    @tuscala 4 місяці тому +12

    Man, this is the greatest tutorial video that I've ever seen!

  • @yanfung9081
    @yanfung9081 4 місяці тому

    You always deliver an amazing UA-cam tutorial for the viewers! Your explanations are always spot on! Thank you so much!!! :)

  • @bigbadcatbigbcy2933
    @bigbadcatbigbcy2933 Місяць тому

    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

  • @AlfredoGuako
    @AlfredoGuako 2 місяці тому

    this was incredibly helpful, got my first custom domain web app running!

  • @georgemwaniki
    @georgemwaniki 16 днів тому

    Your way you explain things makes you one of the best tutor i know, Thank you so much

  • @Beyram1501
    @Beyram1501 3 місяці тому

    Man your videos are amazing and really clear. you gained a subscriber. Thanks

  • @user-iz2ge2fl4x
    @user-iz2ge2fl4x 2 місяці тому

    Thanks so much, your way of teaching makes things simpler. Waiting for more videos 💫

  • @ApeToot
    @ApeToot Місяць тому

    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!

  • @armaandhanji7151
    @armaandhanji7151 4 місяці тому +1

    Fantastic walkthrough!

  • @michaelzinzun-zu1py
    @michaelzinzun-zu1py 13 днів тому

    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

  • @samyip
    @samyip 6 днів тому

    Brilliant tutorial !!

  • @ecko3383
    @ecko3383 2 місяці тому

    You are incredible kind sir. Thank you for this

  • @ShreyasSreedhar2
    @ShreyasSreedhar2 Місяць тому

    Super helpful, Thanks!

  • @manuel.blanco
    @manuel.blanco Місяць тому

    Thanks, this helped me a lot!!

  • @SonAyoD
    @SonAyoD 4 місяці тому

    Great plugins thanks!

  • @khashe
    @khashe 3 місяці тому

    This was really great.

  • @youssouf.abachouch
    @youssouf.abachouch Місяць тому

    the best tutorial, thank you so much

  • @arieladalid9910
    @arieladalid9910 14 годин тому

    Really nice explained
    thank you

  • @rangaswamireddy8683
    @rangaswamireddy8683 4 місяці тому

    Fantastic the way you explained. And i request you make a tutorial on pm2 load balancer etc... thanks

  • @ImpendingSole13
    @ImpendingSole13 4 місяці тому

    You're amazing. Thanks alot !!

  • @courtneynel7433
    @courtneynel7433 3 місяці тому

    This is a really great video.

  • @JunaidAzizChannel
    @JunaidAzizChannel 5 днів тому

    Insane value!!

  • @bigbrain720
    @bigbrain720 Місяць тому

    broooo this video is so solid

  • @quangtranoannhat2930
    @quangtranoannhat2930 4 місяці тому

    awesome !!! love this content

  • @thequang9234
    @thequang9234 4 місяці тому

    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!

  • @yemam4156
    @yemam4156 Місяць тому

    Thanks bro a lot for this tutorial

  • @erlend1587
    @erlend1587 4 місяці тому

    Great tutorial! I did something similar using Linode, but used nginx instead of Caddy. Caddy seem like a simpler choice with the automated ssl.

    • @SamMeechWard
      @SamMeechWard  4 місяці тому +1

      I only recently started using it, but it's been awesome and I trust the community behind it

  • @dekooks1543
    @dekooks1543 4 місяці тому

    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

    • @SamMeechWard
      @SamMeechWard  4 місяці тому

      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

  • @Tubee1234
    @Tubee1234 3 місяці тому

    really amazing tutorial

  • @elitdesign3867
    @elitdesign3867 4 місяці тому +1

    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)?

  • @endfine9230
    @endfine9230 20 днів тому

    Thank you!

  • @kjsharp
    @kjsharp 3 місяці тому

    Fantastic video

  • @AdarshMadrecha
    @AdarshMadrecha 2 місяці тому +1

    Can you do a follow-up video, just covering changes required if using Bun instead of Node Js?

  • @XavierTheRapper
    @XavierTheRapper 2 місяці тому

    Dope!!!!!

  • @anjanshomodder6463
    @anjanshomodder6463 4 місяці тому

    Really helpful video. Would be nice if you could create a video about how to automate all these stuff with github actions. Thanks

  • @ustav_o
    @ustav_o Місяць тому

    absolute legend

  • @noahmilliken4259
    @noahmilliken4259 4 місяці тому +2

    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?

  • @valtronicsza
    @valtronicsza 6 днів тому

    Thanks!

  • @MilindMishra
    @MilindMishra 4 місяці тому

    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 ?

  • @dianab536
    @dianab536 8 днів тому

    Can you please make video setting up Nginx to Nextjs? Definitely an insightful video, thank you for introducing me to caddy. 😊

  • @ervispojana118
    @ervispojana118 Місяць тому

    Thank you !!!

  • @somnathgolui2912
    @somnathgolui2912 4 місяці тому

    Great video!
    Can you also tell us how to do continuous delivery?

  • @DheerajKumar-ik4mi
    @DheerajKumar-ik4mi 3 місяці тому

    Have you put the frontend requests to localhost or a specific IP?

  • @solo-yl8uc
    @solo-yl8uc 2 місяці тому

    thank you so much.

  • @charithlakshan8382
    @charithlakshan8382 4 місяці тому +27

    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 ?

    • @khaledsanny4817
      @khaledsanny4817 4 місяці тому +6

      Yeah but it's too much hassle just for this video. You will have to create and delete the repo

    • @israelafangideh
      @israelafangideh 4 місяці тому +2

      Yes, you can

    • @snakefinn
      @snakefinn 3 місяці тому +5

      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

    • @austinm8823
      @austinm8823 2 місяці тому

      ​@snakefinn but he didn't copy over the .env files using rsync either lol.

    • @switchlyrics.
      @switchlyrics. Місяць тому

      imagine u lose ur git account

  • @jcarneiro91
    @jcarneiro91 22 дні тому

    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 ?

  • @omarabdelrahman180
    @omarabdelrahman180 16 днів тому

    Fantastic

  • @Benjaminmcp0
    @Benjaminmcp0 24 дні тому

    Hi I'm new to AWS cloud computing, could you explain why you used EC2 rather than AWS amplify in this instance :)

  • @lebronjaimeslannister
    @lebronjaimeslannister 4 місяці тому

    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

    • @SamMeechWard
      @SamMeechWard  4 місяці тому +1

      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/

  • @marvellousadesanya8480
    @marvellousadesanya8480 3 місяці тому +2

    Any alternatives o rysnc? Does not work on git bash

  • @HenryOsim
    @HenryOsim 4 місяці тому +3

    great video thanks. Can you create a video about doing same with Terraform please?

    • @SamMeechWard
      @SamMeechWard  4 місяці тому

      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.

  • @marioshadj8409
    @marioshadj8409 4 місяці тому

    Thanks for the video! Can you make a video on how to handle new version of the app without downtime?

    • @SamMeechWard
      @SamMeechWard  4 місяці тому +1

      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

  • @bigdinorino
    @bigdinorino 3 місяці тому +3

    at 9:56 how do you go to my app git(main)

  • @andreabiaggi3198
    @andreabiaggi3198 4 місяці тому +1

    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!

  • @haha7836hahah
    @haha7836hahah 4 місяці тому

    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

  • @WIBEDRILLMusic
    @WIBEDRILLMusic Місяць тому

    Hi Sam, can you make one video for the Serverless approach??

  • @sunilmaurya6594
    @sunilmaurya6594 4 місяці тому

    Can u please make video on automatic things?
    Would be appreciated 🙏

  • @jitx2797
    @jitx2797 4 місяці тому +1

    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.

    • @KratosCY
      @KratosCY 2 місяці тому

      Good question and suggestion.

    • @jitx2797
      @jitx2797 2 місяці тому

      I am currently using pm2...For CI CD I found this ua-cam.com/video/fkzpywlJcMA/v-deo.html@@KratosCY

  • @EmanuelCovelli
    @EmanuelCovelli Місяць тому

    I really would like a similar tutorial that uses Docker on ec2

  • @P.Shivakrishna
    @P.Shivakrishna 2 місяці тому

    hey can you explain more about migrate postgres sql db into ec2 how to create migrate.ts file and other things

  • @solo-yl8uc
    @solo-yl8uc 3 місяці тому

    are these all free within free tier usage?

  • @amansagar4948
    @amansagar4948 Місяць тому

    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

  • @MilindMishra
    @MilindMishra 4 місяці тому

    Great work!
    but isnt pm2 a better practice instead of systemd ?

    • @MilindMishra
      @MilindMishra 4 місяці тому

      latter in the video i understood the mindset of you teaching the basics first so it makes sense, thank you!

  • @ramendrasoni3368
    @ramendrasoni3368 26 днів тому

    Can I host many websites on single EC2 instance

  • @UcheagwuOnyike
    @UcheagwuOnyike 4 місяці тому

    Can you share the codebase? Would you like to do some practice? I can't find it on your Github

  • @fahadahad2815
    @fahadahad2815 26 днів тому

    hey i am unable to copy my folder from windows to ubuntu. I got the public key and invalid hostname error. Any solution?

  • @Jeremiahking101
    @Jeremiahking101 2 місяці тому +2

    I have an App.js running on port 3000 and a Server.js (Backend) running on port 5000. How would this work?

    • @kincaidschmitt7811
      @kincaidschmitt7811 2 місяці тому

      +1

    • @vikneswaran6186
      @vikneswaran6186 Місяць тому

      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 .

  • @spare4337
    @spare4337 3 місяці тому

    Can u create SSR on aws with React

  • @MKtechnoverse
    @MKtechnoverse 26 днів тому

    Bro how much it could cost for storing Mern stack

  • @truth8690
    @truth8690 4 місяці тому +2

    great

    • @SamMeechWard
      @SamMeechWard  4 місяці тому +1

      Thanks for watching! I'm glad you enjoyed it.

  • @programmer9809
    @programmer9809 2 місяці тому +1

    👍

  • @martinoveer9483
    @martinoveer9483 3 місяці тому

    OCD speed?

  • @astb01
    @astb01 4 місяці тому

    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 🤔

    • @SamMeechWard
      @SamMeechWard  4 місяці тому +4

      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.

  • @purplemoon-media
    @purplemoon-media 4 місяці тому

    is it okey if I add source code via github ?

  • @rduballday
    @rduballday 4 місяці тому

    Hello , can you point me to the code for this tutorial?

  • @ayushgursal1627
    @ayushgursal1627 2 місяці тому

    It asks for password if i do chmod 400 so what password should i write there for that instance

  • @leanderchristmann2981
    @leanderchristmann2981 4 місяці тому

    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".

  • @phantazzor
    @phantazzor 4 місяці тому

    can you migrate to t2.small later on ?

    • @SamMeechWard
      @SamMeechWard  4 місяці тому

      Yes, you just have to stop the instance first.

  • @prayaspatel6325
    @prayaspatel6325 3 місяці тому

    Don't mind me brother, you look something like Eliot Anderson

  • @abdulganiyuzziwa8555
    @abdulganiyuzziwa8555 Місяць тому +1

    😆😆Dude u actual have a DRIZZLE folder are you in the movement too🤣🤣🤣woow

  • @yazanalzubi5446
    @yazanalzubi5446 2 місяці тому

    Do you have any courses that I can buy? Please take my money

  • @hotwings9382
    @hotwings9382 2 місяці тому

    Couldn't this be done inside nginx?

    • @austinm8823
      @austinm8823 2 місяці тому

      Did you watch the video? Honest question. He addresses that he normally would use Nginx.

  • @vernevens1598
    @vernevens1598 2 місяці тому

    We use AWS to insure more food shortages and plandemics.

  • @user-lx6lp3jg2c
    @user-lx6lp3jg2c 3 місяці тому

    Please show the same detailed video, but deploy the finished project in Amplify + Lambda

    • @SamMeechWard
      @SamMeechWard  Місяць тому

      Honestly, I avoid amplify at all costs. My recommendation is to try SST.dev

  • @yiannis_p
    @yiannis_p 3 місяці тому +1

    Yall never heard of git and docker ?

  • @namesare4fools
    @namesare4fools 4 місяці тому

    this is far from easily, why are you not using SST

    • @SamMeechWard
      @SamMeechWard  Місяць тому

      I love SST, when I want a serverless environment

  • @pruthveshshetkar1263
    @pruthveshshetkar1263 2 місяці тому

    Thanks!