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

解決辦法:找到項目文件夾 右鍵

到此結束 有問題的歡迎留言!~

相關文章
相關標籤/搜索