如何在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 >> file manager >> 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屋!