Jun 25, 2024
Just so you know, you need to have a nextjs application ready to deploy. Because, in this article we’re not going through how to setup nextjs application.
Then, add the following configuration on your next.config file:
const nextConfig = {
...
output: "standalone"
...
};
Never build a production version on your cPanel. Because, usually shared hosting doesn’t have many resources like VPS or Dedicated Server. Therefore, you should build the production on your local machine.
Run the build script, usually yarn build / npm build / bun run build.
After you run the build script. You will get the output inside .next folder. Next step is, you need to compress the output build into .zip file.
We recommend you create a new folder on your local machine to copy the output build. Here’s all the content you need to copy:
Your new folder / production folder will look like this:
Then, you can compress the whole files and folders.
Before you upload the output build, you need to create a new folder first on your file manager.
JustAHost provides Unlimited Hosting with Rich Features such as NodeJS support, Python support, Ruby support, and many more with Low Costs~!
Config your nodejs application
Things to pay attention to:
1. Node.JS version — Make sure you select the correct nodejs version
2. Application mode — Make sure you choose “Production” mode
3. Application root — Folder location of your app (the folder that you already created in the previous step)
4. Application URL — Make sure you already added the domain on cPanel
5. Applicataion startup file — type “server.js”
You were also able to add some Env Variables if needed.
Then, click “Create”.
Now, your nodejs app should be accessible to the public. Don’t forget to point your domain to your cPanel Hosting.