简体   繁体   English

如何在生产中构建 Node js 应用程序以在 IIS 中托管

[英]How to build Node js app in production for hosting in IIS

I have a node js server that I want to deploy on IIS.我有一个节点 js 服务器,我想在 IIS 上部署它。 Since I am new to node, I am unable to understand the following:由于我是节点新手,因此无法理解以下内容:

  • How to bring the code in production mode?如何将代码带入生产模式?

  • How to build the code in production mode?如何在生产模式下构建代码?

  • How to deploy it to IIS如何将其部署到 IIS

Thank you谢谢

You can follow the below steps to deploy the node js app in iis: 1)Install iisnode https://github.com/Azure/iisnode您可以按照以下步骤在 iis 中部署 node js 应用程序: 1)安装 iisnode https://github.com/Azure/iisnode

2)Download and install url rewrite extension 2)下载并安装url重写扩展

3)set the port number in your node app by using below code: process.env.PORT note: use the same port number in iis site bindings 3)使用以下代码在您的节点应用程序中设置端口号: process.env.PORT 注意:在 iis 站点绑定中使用相同的端口号

4)add the site in iis and give your node js app folder path and set the site bindings 4)在 iis 中添加站点并提供您的节点 js 应用程序文件夹路径并设置站点绑定

5)Add below code in web.config file: 5) 在 web.config 文件中添加以下代码:

<configuration>
    <system. Webserver>
    <handlers>
        <add name=""iisnode"" path=""server.js"" verb=""*"" modules=""iisnode"" />
    </handlers>
   <rewrite>
        <rules>
        <rule name=""rule1"">
            <match url=""/*"" />
            <action type=""Rewrite"" url=""server.js"" />
        </rule>
        </rules>
    </rewrite>
    </system. Webserver>
</configuration>

Note: please give the iis_iusrs and iusr full control permission to the site root folder注意:请给站点根文件夹的 iis_iusrs 和 iusr 完全控制权限

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

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