Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rifet's avatar
Level 1

Hosting Laravel & Next.js

My first time trying to host laravel & nextjs app. I have cpanel on my domain. Issue is I don't know how to even start. On my local machine I run npm run dev & php artisan serve so I have my nextjs on localhost:3000 and laravel on localhost:8000

How can I host this now to cpanel? Also on Cpanel there is "setup nodejs app" so I am not sure do I need to use that?

My folder structure is like this: app composer.json database public routes tests artisan composer.lock nextjs README.md server.php vendor bootstrap config phpunit.xml resources storage

Next app is located under nextjs folder. Do I need to make separate domain for laravel api? api.mydomain.com ?

0 likes
3 replies
ollie_123's avatar

@rifet for normal Laravel just change the path on cPanel to yourfolderstructure/projectname/public which will then display your laravel project.

For the nextjs i'm not sure on this. Hopefully someone else can advise.

Rifet's avatar
Rifet
OP
Best Answer
Level 1

I made it work. Update if anyone get the same issue.

On cPanel there is "node js" tab and there I created node server that hosts my nextjs app as server and with some tweaks I managed to make it work.

Here is the url that helped me a lot regarding hosting nextjs on cpanel:

https://www.youtube.com/watch?v=KUBADQ3qhmE

As of laravel, I hosted it on separate domain api.mydomain.com and nextjs is simply calling that domain as BE, works like a charm

Please or to participate in this conversation.