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"
}
}
Thank you so much. I found solution how to deploy and it fix my error during deploy on cpanel😊
Thanks for watching
Keep up the good good work, Thank you
@@blogvlogadvertising4976 Thanks so much for watching 👍
Thank you for this tutorial, it's very straightforward 👍
@@olujobifolaranmi2133 Thanks so much for watching and for your kind words! Glad you found the tutorial helpful. 😊
grate video can u show us how to connect to pgsql database as well
Thanks for watching. I will make tutorial on that soon.
my project in next js TS tailwinds, I do same steps but show 503 error.
@@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
what's your package json
Your script part must contian this in package.json
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js"
Is it the same using app router ?
@@abdullahzafar4401 yes it will also work. If you face any issue tell me in comment.
@@code_lab_9994
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
@@manishgupta7181 I also have tutorial on that goto my channel and you will find deploy static html export on cpanel
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?
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.
@@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.
@@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.
Does this work on app router as well?
I am getting error as i am using app router
Deployment is same for both.
@@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
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?
@@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
can you upload you github?
In video description i have written the package.json scripts part that you needed. I will also put github link later.