简体   繁体   English

在 CPanel 上部署 Nuxt SSR

[英]Deploying Nuxt SSR on CPanel

I am trying to deploy a nuxt app to cpanel shared hosting.我正在尝试将 nuxt 应用程序部署到 cpanel 共享主机。 It is working fine on my local machine using run dev, build and start.使用 run dev、build 和 start 在我的本地机器上运行良好。 However, when I moved the files to cpanel.但是,当我将文件移动到 cpanel 时。 I can run npm dev, build, and start.我可以运行 npm 开发、构建和启动。 When I use npm run dev, an IP and port was generated, I visited this IP and port on my browser but its not working.当我使用 npm 运行开发时,生成了 IP 和端口,我在浏览器上访问了这个 IP 和端口,但它无法正常工作。

How can I make this IP work as well as make the app work with my domain.我怎样才能使这个 IP 工作以及使应用程序与我的域一起工作。

在此处输入图像描述

for run nuxt ssr in cpanel you can use below code and install pm2 in your project:要在 cpanel 中运行 nuxt ssr,您可以使用以下代码并在您的项目中安装 pm2:

1-package.json: 1-package.json:

"config": {
    "nuxt": {
      "host": "0.0.0.0",
      "port": "customport"
    }
  },
  "scripts": {
    "dev": "nuxt --host yourdomain --port customport",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate",
    "deploy": "/opt/cpanel/ea-nodejs10/bin/pm2 start /opt/cpanel/ea-nodejs10/bin/npm --name yourpm2name -- start"
  },

2-.htaccess file 2-.htaccess 文件

RewriteEngine On
RewriteCond %{SERVER_PORT} 443
RewriteRule ^index.php(.*) http://yourdomain::customport/$1 [P,L]
RewriteRule (.*) http://yourdomain:customport/$1 [P,L]

3- run this code: npm run build 4- and then: pm2 start yourpm2name 3-运行此代码:npm 运行构建 4-然后:pm2 start yourpm2name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM