How to deploy Next.js project to cPanel | Create custom server | Deploy Production Build in cPanel

Поделиться
HTML-код
  • Опубликовано: 20 сен 2024
  • In this tutorial, We will deploy next.js project with prodution build in cpanel. When we deploy it in production it is really fast than the developemnt build.
    Next.js creates issues when we deploy it to the cpanel with production. But we will solve those issue as well for deploying it to the cPanel.
    In package.json include these scripts:
    {
    "scripts": {
    "dev": "node server.js",
    "build": "next build",
    "start": "NODE_ENV=production node server.js"
    }
    }

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

  • @Waqas-b1u
    @Waqas-b1u 20 дней назад +3

    Thank you so much. I found solution how to deploy and it fix my error during deploy on cpanel😊

  • @blogvlogadvertising4976
    @blogvlogadvertising4976 29 дней назад +3

    Keep up the good good work, Thank you

    • @code_lab_9994
      @code_lab_9994  29 дней назад

      @@blogvlogadvertising4976 Thanks so much for watching 👍

  • @olujobifolaranmi2133
    @olujobifolaranmi2133 Месяц назад +1

    Thank you for this tutorial, it's very straightforward 👍

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

      ​@@olujobifolaranmi2133 Thanks so much for watching and for your kind words! Glad you found the tutorial helpful. 😊

  • @BiniyamYoseph-t7j
    @BiniyamYoseph-t7j 9 дней назад +1

    grate video can u show us how to connect to pgsql database as well

    • @code_lab_9994
      @code_lab_9994  9 дней назад

      Thanks for watching. I will make tutorial on that soon.

  • @manishbhusal-fq2vv
    @manishbhusal-fq2vv 8 дней назад +1

    my project in next js TS tailwinds, I do same steps but show 503 error.

    • @code_lab_9994
      @code_lab_9994  8 дней назад

      @@manishbhusal-fq2vv make your build locally, and as a last step after running project unzip the .next folder in cpanel project directory. If solution works make sure to press subscrb channel

  • @LanaGames.
    @LanaGames. 14 дней назад +1

    what's your package json

    • @code_lab_9994
      @code_lab_9994  13 дней назад

      Your script part must contian this in package.json
      "dev": "node server.js",
      "build": "next build",
      "start": "NODE_ENV=production node server.js"

  • @abdullahzafar4401
    @abdullahzafar4401 День назад +1

    Is it the same using app router ?

    • @code_lab_9994
      @code_lab_9994  День назад

      @@abdullahzafar4401 yes it will also work. If you face any issue tell me in comment.

    • @abdullahzafar4401
      @abdullahzafar4401 День назад

      @@code_lab_9994

  • @manishgupta7181
    @manishgupta7181 26 дней назад +2

    is there a way to do it with out folder? because for my project .next folder is quite large , also i tried doing it with out folder but its causing problems in routing

    • @code_lab_9994
      @code_lab_9994  26 дней назад

      @@manishgupta7181 I also have tutorial on that goto my channel and you will find deploy static html export on cpanel

  • @robiulhasan1028
    @robiulhasan1028 Месяц назад +1

    brother, i am working on app router and using middleware.js file for authentication. but, the middleware not working on the shared host. can you help me on this?

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

      try to make middleware.js file in the project root folder instead of pages directory. If you are using src/app then move this in src folder instead of src/app. Hope this helps.

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

      @@code_lab_9994 i am using app router and the middleware.js file is already in the src folder. but it's not working. basically, i get not-found page for the routes which are mentioned in the matcher isndie the middleware.js file.

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

      @@code_lab_9994 i am working on the app router and the middleware file is already on the src folder. but not working as expected. basically, i am getting not found page for all the routes which are mentioned in the matcher inside the middleware.

  • @maneeshsingh3038
    @maneeshsingh3038 10 дней назад +1

    Does this work on app router as well?
    I am getting error as i am using app router

    • @code_lab_9994
      @code_lab_9994  10 дней назад

      Deployment is same for both.

    • @maneeshsingh3038
      @maneeshsingh3038 7 дней назад

      ​@@code_lab_9994I am unable to deploy view .next folder on my cpanel .. While I try to redeploy .next folder,it says the folder already exists, but it is not showing in cpanel

    • @maneeshsingh3038
      @maneeshsingh3038 7 дней назад

      Apparently I am getting error while running JS script build which says
      'out of memory error may be caused by hitting LVE limits or "Max data size","Max address space" or "Max resident set" process limits.Please check LVE limits and process limits.'
      How to deal with this error?
      Any idea?

    • @code_lab_9994
      @code_lab_9994  7 дней назад

      @@maneeshsingh3038 you should not run JS script there instead you should create build locally and paste .next folder at last step and restart app as i did in video

  • @LanaGames.
    @LanaGames. 14 дней назад +1

    can you upload you github?

    • @code_lab_9994
      @code_lab_9994  5 дней назад

      In video description i have written the package.json scripts part that you needed. I will also put github link later.