如何在 cpanel 上部署 nextjs 应用程序? [英] How to deploy a nextjs application on cpanel?
问题描述
我按照这些步骤在 cPanel 上部署了我的 nextjs.
I followed these steps to deploy my nextjs on cPanel.
转到 package.json 并添加以下行:
"homepage": "http://afsanefadaei.ir"
运行 next build
以将 .next
文件夹作为我的构建文件夹
run next build
to have .next
folder as my build folder
转到 cpanel >>文件管理器>>public_html
文件夹并将.next
文件夹的内容上传到该目录
go to cpanel >> file manager >> public_html
folder and upload the contetn of .next
folder to this directory
添加或编辑此文件:.htaccess
至:
add or edit this file: .htaccess
to:
但是当我访问该网站时,我遇到了这样的问题:
but when I go to the website I face this:
你知道这有什么问题吗?
Do you know what is wrong with this?
推荐答案
- 您的
.next
没有 index.html 文件. - 似乎您有服务器端(主要使用 nodejs),但不幸的是您无法从 cpanel 运行该服务器端.
- 据我所知,如果您倾向于只有前端,则应该使用
next export
而不是next build
.
- Your
.next
doesn't have index.html file. - Seems like you have server side (mostly using nodejs), but unfortunately you couldn't run that server side from cpanel.
- As I know, you should use
next export
instead ofnext build
if you tend to have frontend side only.
但最重要的是第 1 点,请确保您的 .next
文件夹中有 index.html
.
But the most important thing is number 1, make sure you have index.html
inside your .next
folder.
这篇关于如何在 cpanel 上部署 nextjs 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!