zoukankan      html  css  js  c++  java
  • iis服务器上部署node.js解决方法

    以下所有内容都是在iis服务器配置成功的基础上

    1. 安装 node.js,官网下载 node.exe(用express的再安装express),这步略过。

    2. 安装 iisnode,https://github.com/tjanczuk/iisnode/wiki/iisnode-releases,IIS运行 node.js 的关键。

    3. 安装 url-rewrite,http://www.iis.net/downloads/microsoft/url-rewrite

    4. 将项目放到指定文件夹下,在这个文件夹下新建一个web.config文件。

         web.config文件中的内容 

    <configuration>
      <system.webServer>
    
        <!-- indicates that the hello.js file is a node.js application 
        to be handled by the iisnode module -->
    
        <handlers>
            <add name="iisnode" path="index.js" verb="*" modules="iisnode" resourceType="Unspecified" requireAccess="Script" preCondition="bitness64" />
        </handlers>
        
        <rewrite>
                <rules>
                    <rule name="all">
                        <match url="/*" />
                        <action type="Rewrite" url="index.js" />
                    </rule>
                </rules>
        </rewrite>    
        
        <iisnode 
            node_env="%node_env%" 
            nodeProcessCountPerApplication="1" 
            maxConcurrentRequestsPerProcess="1024" 
            maxNamedPipeConnectionRetry="100" 
            namedPipeConnectionRetryDelay="250" 
            maxNamedPipeConnectionPoolSize="512" 
            maxNamedPipePooledConnectionAge="30000" 
            asyncCompletionThreadCount="0" 
            initialRequestBufferSize="4096" 
            maxRequestBufferSize="65536" 
            watchedFiles="*.js;node_modules*;routes*.js;views*.jade" 
            uncFileChangesPollingInterval="5000" 
            gracefulShutdownTimeout="60000" 
            loggingEnabled="true" 
            logDirectory="iisnode" 
            debuggingEnabled="true" 
            debugHeaderEnabled="false" 
            debuggerPortRange="5058-6058" 
            debuggerPathSegment="debug" 
            maxLogFileSizeInKB="128" 
            maxTotalLogFileSizeInKB="1024" 
            maxLogFiles="20" 
            devErrorsEnabled="true" 
            flushResponse="false" 
            enableXFF="false" 
            configOverrides="iisnode.yml" 
            nodeProcessCommandLine="C:Program Files
    odejs
    ode.exe" 
            promoteServerVars="REMOTE_ADDR" />
            
            <defaultDocument>
                <files>
                    <add value="index.js" />
                </files>
            </defaultDocument>
          
        <!--     
        
        One more setting that can be modified is the path to the node.exe executable and the interceptor:
        
        <iisnode
          nodeProcessCommandLine="&quot;%programfiles%
    odejs
    ode.exe&quot;" 
          interceptor="&quot;%programfiles%iisnodeinterceptor.js&quot;" />
        
        -->
    
      </system.webServer>
    </configuration>
      其中<add name="iisnode" path="index.js" verb="*" modules="iisnode" resourceType="Unspecified" 
    requireAccess="Script" preCondition="bitness64" />里的path="index.js"对应node项目入口文件路径
      nodeProcessCommandLine="C:Program Files
    odejs
    ode.exe"   这个是node.exe的安装路径

    5.index.js中端口监听原先写法是 server.listen(8080) 改成 server.listen(process.env.PORT||8080)

  • 相关阅读:
    TF-IDF与余弦类似性的应用(一):自己主动提取关键词
    三层中的大学问
    浅析JavaBean
    查看和改动MySQL数据库表存储引擎
    菜鸟之路--线性表__链表实现
    STL_算法_元素计数(count、count_if)
    ZOJ 3691 Flower(最大流+二分)
    字符的编码与解码
    主动訪问用户数据的背后是品牌战略
    输入n,求1~n累加
  • 原文地址:https://www.cnblogs.com/pony-Bug/p/13029967.html
Copyright © 2011-2022 走看看