【问题标题】:How can deploy Angular universal on windows server如何在 Windows 服务器上部署 Angular 通用
【发布时间】:2020-11-10 17:19:02
【问题描述】:

我无法将我的网站部署(发布)为 Angular Universal,我几乎尝试了所有方法。

当我在 localhost 中运行 npm run dev:ssr 时,它运行良好,我可以看到页面源甚至是动态的。

在我的dist 文件夹中:

  • 分布
    • 浏览器(包括index.html等..)
    • 服务器(包括main.js

我阅读了iisnod 以将其设置在web.config 中,但我无法将结果作为服务器端页面,我的问题是我如何在我的网站上发布 Angular 通用(IIS) ?

我该怎么办?

【问题讨论】:

  • 也许你最好在你的 iis 上使用 asp.net,然后使用 angular universal 的aspnetcore-engine
  • 显示你的问题配置

标签: angular web-config angular-universal


【解决方案1】:

将 Angular SSR 部署到 IIS 是一种不好的做法。 使用 Node.js 和 PM2 https://pm2.keymetrics.io/

在 Windows Server 上部署的步骤

  1. 安装 Node.js
  2. 安装 PM2
    • 输入命令'npm i pm2@latest -g'
  3. 构建 Angular 应用
  4. /dist/** 过滤器部署到服务器。
  5. 关注
  6. 启动 PM2
    • 键入命令'pm2 start --name '
  7. 享受

PM2 运行 Node.js 服务器。如果要重新部署应用程序,请在部署后重新启动 PM2。命令 - 'pm2 respart '

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-12
    • 2021-03-22
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多