iis 和 node express 共用80端口 iisnode 全过程

1、首先下载iisnode.exe node

https://github.com/tjanczuk/iisnode/wiki/iisnode-releases  连接git

 

安装完毕!github

2、打开IIS 7  web

选中 Default Web Site  右侧app

一、选择浏览   删除文件夹内的东西   而后把项目复制进这个文件夹下面ide

二、点击绑定 IP 域名ui

 

 

项目根目录下 新建 Web.config 文件 内容以下:this

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>    
        <handlers>
            <add name="iisnode" path="launch.js" verb="*" modules="iisnode" resourceType="Unspecified" requireAccess="Script" />
        </handlers>            
        <iisnode promoteServerVars="REMOTE_ADDR" watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" /> 
        <rewrite>
            <rules>
                <rule name="all" patternSyntax="Wildcard">
                    <match url="*" />
                    <action type="Rewrite" url="launch.js" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

项目根目录下 新建 launch.js 文件  内容以下:url

#!/usr/bin/env node

require('./bin/www');

 而后浏览 域名就OK了!spa

若是出现: 

iisnode encountered an error when processing the request.

HRESULT: 0x2 
HTTP status: 500 
HTTP reason: Internal Server Error 
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.

The node.exe process has not written any information to stderr or iisnode was unable to capture this information. Frequent reason is that the iisnode module is unable to create a log file to capture stdout and stderr output from node.exe. Please check that the identity of the IIS application pool running the node.js application has read and write access permissions to the directory on the server where the node.js application is located. Alternatively you can disable logging by setting system.webServer/iisnode/@loggingEnabled element of web.config to 'false'.

解决办法:找到项目文件夹 右键

到此结束 有问题的欢迎留言!~

相关文章
相关标签/搜索