我按照这个教程来部署我的nextjs应用程序到cPanel上的共享主机。
Road map for deploying on cPanel Next App with server-side rendering (not only static) :
Build locally (next build)
Copy into html_folder all your project directory (not only the build folder, and except node_modules of course) :
public_html
my_project
.next
src
server.js
package.json
...
Note: A custom server is needed as cPanel needs a startup file (use the next's default one)
create your node application ("setup node.js app") with options :
Application root : public_html/my_project
Application startup file : server.js
...
"Run NPM install" to create node_modules packages
Finally "Start App"
package.json with the start command :
"scripts": {
"start": "cross-env NODE_ENV=production node server.js"
}
然而,访问我的网站后,经历了整个过程给我这个错误:
2条答案
按热度按时间yhived7q1#
您真正需要做的就是运行
next build && next export
,并将out文件夹的内容放在public_html文件夹或/var/www/html/、/sites-available/等文件夹中,具体取决于设置。k10s72fa2#
确保将**.next**文件夹复制到cpanel的文件夹中,如下所示:
我的项目--〉cpanel中的文件夹|.下一个|--〉这个文件夹____________源服务器. js包. json...
如果在项目中看不到此文件夹,请启用显示隐藏文件的选项。