How To Deploy NextJS With Nginx and PM2

Поделиться
HTML-код
  • Опубликовано: 18 дек 2024

Комментарии • 75

  • @jeff6555
    @jeff6555 6 месяцев назад +2

    It's probably very obvious to anyone that has already set up their environment in the past, but the test connection at 10:13 will fail unless you've added your public key to your github account.

  • @KhalidBoussaroual
    @KhalidBoussaroual 4 месяца назад +3

    One of the greatest tutorials I have ever seen.

  • @prashantaarya3852
    @prashantaarya3852 20 дней назад +1

    You are 💎 So detailed and easy to understand ❤

  • @oussamafahchouch6871
    @oussamafahchouch6871 2 года назад +4

    Thanks for this great NextJS with Nginx tutorial! Including SSL setup :)!

  • @LachCrafter
    @LachCrafter 7 месяцев назад +1

    thank you so much! It was my dream to have a system like that! Keep it up!

  • @manishpaudel6515
    @manishpaudel6515 Год назад +1

    I have server side to my nextjs app with api folder and the frontend is not being able to access the endpoint in pm2 next js; how do I resolve that?

  • @ianvieira283
    @ianvieira283 Год назад

    Can i ask you something? My nextjs app is running just fine, but everyday at 05:00 some "check status" runs in my t2.micro and get "1/2 verified status", and it gets "down", do you know what it would be? :/ everyday at determinated time.... 05:00 or 06:00

  • @nri_raj
    @nri_raj Месяц назад

    How to do this on windows server please

  • @excalibur2417
    @excalibur2417 2 года назад +1

    This video was oddly satisfying to watch

  • @DuongNguyen-yv9lj
    @DuongNguyen-yv9lj 12 дней назад

    Hi, if i have a custom server in root name is server.ts to handle socketIO so this deploy still working right

    • @fullstackbook
      @fullstackbook  11 дней назад

      You'd probably need to set up a proxy in Nginx to route socket requests to the custom server. Maybe the custom server could be run as a separate process.

  • @tarikcodes
    @tarikcodes 4 месяца назад

    how to handle copying `.env.local` from the ecosystem file

    • @fullstackbook
      @fullstackbook  4 месяца назад

      you might be able to use the `dotenv` package to load env variables into the file. never tried this before. not sure how it would affect production.

  • @ICOReviewtoken
    @ICOReviewtoken Год назад

    I only have 1 last step left but I get an error when Permission denied (publickey).

  • @transcendmoney
    @transcendmoney 8 месяцев назад +1

    thanks, very much. Great tutorial

  • @nandanvasista7547
    @nandanvasista7547 2 года назад

    Thank you so much
    My Question is
    After doing some changes locally and committing it to git hub
    how to make sure that those changes are reflected in the production

    • @fullstackbook
      @fullstackbook  2 года назад

      You have to run the deployment command. Or set up a CI/CD pipeline to automate the deployment.

    • @nandanvasista7547
      @nandanvasista7547 2 года назад

      @@fullstackbook Thanks pal

    • @兼明-p2b
      @兼明-p2b 2 года назад

      jenkins you need

  • @forrestm.1968
    @forrestm.1968 Год назад +1

    This helped me tremendously! I got my application deployed. Does anyone know how to set up your environment variables in production? I'm using an EC2 instance like the video to host my application.

    • @fullstackbook
      @fullstackbook  Год назад

      There are different ways to do it. You can add them to .bashrc. Or add them to /etc/environment. Or use AWS Parameter Store.

  • @vernevens1598
    @vernevens1598 9 месяцев назад

    What do I need from Git?

  • @gonzalogdv
    @gonzalogdv 2 года назад

    Great video! Thank you! Which is the proper way to bring changes in GitHub repository to production?

    • @fullstackbook
      @fullstackbook  2 года назад +1

      Run the `pm2 deploy production` command after you push changes to GitHub.

  • @arturfil
    @arturfil 2 года назад +2

    really good video! I have a question though, is there a potential risk of having the .pem file at the level of the project? Shouldn't we avoid that and if not, obviously we would put that in the .gitignore file but just wondering how to go about this.

    • @fullstackbook
      @fullstackbook  2 года назад +5

      You can add it to the .gitignore file to prevent it from getting checked in.

  • @juanpedro_mario
    @juanpedro_mario Год назад

    Thanks for the tutorial
    Can I do this with yarn instead?

  • @yash1o1
    @yash1o1 2 года назад +1

    Just amazing!!! Helped me a ton. Thank you :)

  • @TheNoblegaz
    @TheNoblegaz 9 месяцев назад +1

    Thanks you very much 👌

  • @Matthias53787
    @Matthias53787 5 месяцев назад

    The IP address won't change?

  • @vivekgautamj
    @vivekgautamj Год назад

    Great work there , Just wanted to know how should be handling DB connection on prod server and other config files there ? . Help is really appreciated .
    Thanks again

    • @fullstackbook
      @fullstackbook  Год назад

      Check out my other tutorial ruclips.net/video/b73UwoeoWFw/видео.html

  • @shawnlee5956
    @shawnlee5956 2 года назад +1

    ubuntu 1 GiB Memory able to perform "npm run build"
    mine 512 Mb RAM ubuntu cant do that, need to manually copy and paste the zip to server.
    so far next js is good.
    Thanks for the video. I Learn new things here.

    • @fullstackbook
      @fullstackbook  2 года назад +1

      Probably need a larger compute instance.

  • @Jonasprodrigues
    @Jonasprodrigues Год назад

    I don't understand what is key.pem?

    • @fullstackbook
      @fullstackbook  Год назад +1

      pem file is used as a key to ssh into the server. The “key” part is an arbitrary name I gave it.

    • @Jonasprodrigues
      @Jonasprodrigues Год назад

      @@fullstackbook I understand.. I was confused, I didn't know if it was the public key of git or the server! Thanks 🙏

    • @moustafakamalalimohammad4041
      @moustafakamalalimohammad4041 Год назад

      what key to include it that file?

  • @foxtractnotus928
    @foxtractnotus928 Год назад

    how did you solve the github permission denied thingy

    • @fullstackbook
      @fullstackbook  Год назад

      Did you make sure you have forward agent set? ruclips.net/video/IwWQG6lEdQQ/видео.html

    • @foxtractnotus928
      @foxtractnotus928 Год назад

      @@fullstackbook no no i fixed it , it works now ,just that it is not allowing me to open the site becouse of some hydration thingy

  • @the_egyptian_smough
    @the_egyptian_smough Год назад

    Great video, wanted to know how would you add environment variables for this nextjs project and how to configure AWS CodePipeline that works well with this configuration? thank you again :)

    • @fullstackbook
      @fullstackbook  Год назад

      Not sure what the best practice for handling environment vars on an ubuntu server. Maybe put them into .bashrc? Haven't used CodePipeline before. I have some videos on CircleCi, which I believe serves the same purpose.

  • @AdamDrumm
    @AdamDrumm Год назад

    Your link in the description is broken good sir.

  • @cubeking.minmin
    @cubeking.minmin Год назад

    Thumbs * 1000. Great Video. Don't remove the video.

  • @shakibahmed8698
    @shakibahmed8698 Год назад

    Hi there your link is not working.

  • @julioantoniogonzalezmartin3306
    @julioantoniogonzalezmartin3306 2 года назад +1

    WOW you are incredible.

  • @foxtractnotus928
    @foxtractnotus928 Год назад

    please do with next13

    • @fullstackbook
      @fullstackbook  Год назад

      The steps should be very similar, if not the same.

    • @foxtractnotus928
      @foxtractnotus928 Год назад

      @@fullstackbook allthough nginx is enabled i cant access the simple nginx website ,any advice

  • @jagjot1697
    @jagjot1697 Год назад +1

    great video!

  • @emooboyz
    @emooboyz Год назад

    For PM2, why do i need to set the key in ecosystem.config?

    • @fullstackbook
      @fullstackbook  Год назад

      Maybe you could try setting your public ssh key on the server instead?

  • @priyankaraut8856
    @priyankaraut8856 2 года назад +1

    [PM2][WARN] Applications index, service-worker not running, starting...
    [PM2][ERROR] Error: Script not found: /home/ubuntu/source/index.js
    [PM2][ERROR] Error: Script not found: /home/ubuntu/source/service-worker
    post-deploy hook failed
    Deploy failed
    Deploy failed with exit code: 1

  • @lucky_number
    @lucky_number Год назад

    it great !!! thank u! please help me create pipeline countinues

  • @bassam.2023
    @bassam.2023 Год назад

    Really excellent tutorial! 😀Thanks!

  • @FelipeGenuino
    @FelipeGenuino Год назад +1

    Obrigado, salvou meu dia

  • @pedrohenrique3727
    @pedrohenrique3727 Год назад

    Você é uma lenda!!!!

  • @mohamedyoussef8835
    @mohamedyoussef8835 Год назад

    Awesome video ++++++++++++++ 🙂

  • @merictunc
    @merictunc 8 месяцев назад

    like a pro

  • @drivebuss8079
    @drivebuss8079 Год назад

    such a waste and a grabage.

  • @lshcyrus1228
    @lshcyrus1228 8 месяцев назад

    Hello, thank you for the great tutorial. I am currently facing an error during npm install when running the "pm2 deploy production" command. here is the error:
    $ pm2 deploy production
    --> Deploying to production environment
    --> on host 18.166.xxx.xx
    ○ deploying origin/main
    ○ executing pre-deploy-local
    ○ hook pre-deploy
    ○ fetching updates
    ○ full fetch
    Fetching origin
    ○ resetting HEAD to origin/main
    HEAD is now at f9ac097 Delete package-lock.json
    ○ executing post-deploy `source ~/.nvm/nvm.sh && npm install && npm run build && pm2 reload ecosystem.config.js --env production`
    [2941:0x5dc0190] 17605 ms: Scavenge 430.4 (452.1) -> 429.3 (451.7) MB, 2.52 / 0.02 ms (average mu = 0.662, current mu = 0.625) allocation failure;
    [2941:0x5dc0190] 18090 ms: Mark-Compact (reduce) 461.5 (481.1) -> 457.5 (468.1) MB, 168.28 / 0.03 ms (+ 159.1 ms in 44 steps since start of marking, biggest step 19.4 ms, walltime since start of marking 485 ms) (average mu = 0.613, current mu = 0.565)
    FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
    ----- Native stack trace -----
    1: 0xb84bd6 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [npm install]
    2: 0xefeb90 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [npm install]
    3: 0xefee77 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [npm install]
    4: 0x1110885 [npm install]
    5: 0x1128708 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [npm install]
    6: 0x10fe821 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [npm install]
    7: 0x10ff9b5 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [npm install]
    8: 0x10dc0d6 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [npm install]
    9: 0x10cdd04 v8::internal::FactoryBase::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [npm install]
    10: 0x10d04e6 v8::internal::FactoryBase::NewRawOneByteString(int, v8::internal::AllocationType) [npm install]
    11: 0x1241cb5 v8::internal::JsonParser::MakeString(v8::internal::JsonString const&, v8::internal::Handle) [npm install]
    12: 0x1247ccd [npm install]
    13: 0x1249c39 v8::internal::JsonParser::ParseJson(v8::internal::Handle) [npm install]
    14: 0xf9086e v8::internal::Builtin_JsonParse(int, unsigned long*, v8::internal::Isolate*) [npm install]
    15: 0x1971df6 [npm install]
    bash: line 1: 2941 Aborted (core dumped) npm install
    post-deploy hook failed
    Deploy failed
    Deploy failed with exit code: 1
    This error occurred starting from the 2nd time running the command. For the first time, ubuntu stuck during the "creating optimise pages" stage, and the app was never deployed too. Would greatly appreciate any help, thanks.

    • @fullstackbook
      @fullstackbook  8 месяцев назад +1

      Kind of looks like you're running out of memory. You probably need a larger compute instance.

  • @IleniaQuintero
    @IleniaQuintero 5 месяцев назад

    Hello,
    I was looking at your video channel. We may be helping a company that uses secure images to increase supply chain security and help cloud native development. Would you be willing to help try their software, make a video, and help show devs how to use their tools?
    This is not an offer, but just to start a conversation about your willingness to take on sponsorship. Please provide me with your email if you are interested.
    You'd have a chance to look at their technology and decide if it's the type of software that you'd be interested in covering in your channel.

    • @fullstackbook
      @fullstackbook  5 месяцев назад

      which company is it?

    • @IleniaQuintero
      @IleniaQuintero 5 месяцев назад

      @@fullstackbook Thank you for your response. Can you please provide me with your email so I can provide more information?

    • @IleniaQuintero
      @IleniaQuintero 4 месяца назад

      @@fullstackbook Hello, if you provide me with your email, I can send you more information.