如何在 cpanel 上部署 nextjs 应用程序? [英] How to deploy a nextjs application on cpanel?

查看:29
本文介绍了如何在 cpanel 上部署 nextjs 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这些步骤在 cPanel 上部署了我的 nextjs.

I followed these steps to deploy my nextjs on cPanel.

  1. 转到 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?

推荐答案

  1. 您的 .next 没有 index.html 文件.
  2. 似乎您有服务器端(主要使用 nodejs),但不幸的是您无法从 cpanel 运行该服务器端.
  3. 据我所知,如果您倾向于只有前端,则应该使用 next export 而不是 next build.
  1. Your .next doesn't have index.html file.
  2. Seems like you have server side (mostly using nodejs), but unfortunately you couldn't run that server side from cpanel.
  3. As I know, you should use next export instead of next 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆