看了http://www.cnblogs.com/ciznx/articles/run-nodejs-within-iis-on-windows.html之后,Andy尝试了Node.js的Hello World.
其他就不罗嗦了,看步骤:
一. 安装node.exe,使JS能在服务器端运行。
1.安装node.exe. http://nodejs.org/#download
2.到C:\Program Files (x86)\nodejs,找到node.exe,copy到c:\node。
3.打开cmd。
C:\node>node.exe -v 查看版本。
4.写一个sample如下,保存为D:\HelloWorld.js
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<h1>Cool Nodejs Web Server</h1>');
}).listen(1889, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1889/');
5.C:\node>node.exe D:\HelloWorld.js,结果如下:
Server running at http://127.0.0.1:1889/
打开http://localhost:1889/看到网页效果。
二.安装iisnode,使Node.js的web app在IIS上运行:
1.安装iisnode,https://github.com/tjanczuk/iisnode/archives/master,但我安装的是iisnode-full-iis7-v0.1.14-x64.msi。
2.去\AppData\Local\iisnode,把www copy到别处,比如E:\Node.JS,给www赋予user写权限。
3.在iis7中建立一个app pool:Node Apps。
4.建立site:Node.JS,路径E:\Node.JS。
5.打开http://localhost:1888/helloworld/hello.js,显示iisnode的sample。
Node.js 在 Windows 的 IIS 中的配置完成!
浙公网安备 33010602011771号