2

我在 Visual Studio 2019 上创建了 Node.js 应用程序,我想将它部署在 IIS 上。

如何在本地系统的 IIS 上部署 node.js 应用程序和 Node.js express 应用程序

我尝试了许多解决方案,但没有一个完全有用下面的链接有些有用但令人困惑,还有很多内容需要阅读 https://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx

4

1 回答 1

0

这里有一些针对上述问题的简单解决方案

iss 上的 Node.js 部署

安装 IISNODE open cmd as admin cd "C:\Program Files\iisnode" (或 "C:\Program Files (x86)\iisnode" 如果您安装的是 32 位版本

键入 setupsamples.bat

使用 Web 安装程序安装 MS URL 重写

使用代码添加 web.config

<configuration>
                    <system.webServer>

                        <!-- indicates that the server.js file is a node.js application
                        to be handled by the iisnode module -->

                        <handlers>
                            <add name="iisnode" path="server.js" verb="*" modules="iisnode" />
                        </handlers>

                        <rewrite>
                            <rules>
                                <rule name="sendToNode">
                                    <match url="/*" />
                                    <action type="Rewrite" url="server.js" />
                                </rule>
                            </rules>
                        </rewrite>

                    </system.webServer>
                </configuration>

发布 node.js 项目

将发布的站点粘贴到 inetpub-->wwwroot 以管理员身份运行 cmd 在网站文件夹上运行命令 对于节点
npm install 对于节点 Express npm install express 创建 IIS 网站 开始浏览

于 2019-07-04T06:01:58.473 回答