简体   繁体   中英

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. 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

Thank you

You can follow the below steps to deploy the node js app in iis: 1)Install iisnode https://github.com/Azure/iisnode

2)Download and install url rewrite extension

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

4)add the site in iis and give your node js app folder path and set the site bindings

5)Add below code in web.config file:

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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