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)

  • 相关阅读:
    SQL Server存储过程(二)
    WPF 小知识 (设置背景图)
    关于SQL Server中索引使用及维护简介
    学习asp.net比较完整的流程(转)
    web开发常用默认端口
    接口和类的几大区别
    WEB建站规划之建站目的
    个人经验:页面无刷新传输数据的多种方法总结
    旅游电子商务探讨
    vs2008中文版提供下载(包含中文msdn)
  • 原文地址:https://www.cnblogs.com/pony-Bug/p/13029967.html
Copyright © 2011-2022 走看看