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

一、首先下载iisnode.exe 

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

 

安装完毕!

二、打开IIS 7  

选中 Default Web Site  右侧

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

2、点击绑定 IP 域名

 

 

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

<?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 文件  内容如下:

#!/usr/bin/env node

require('./bin/www');

 然后浏览 域名就OK了!

如果出现: 

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

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

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

 

posted @ 2019-01-22 14:02  萧飒昵称  阅读(450)  评论(0编辑  收藏  举报