Nodejs wanted to play with it a long time ago, but I didn’t have time. I spent 4 hours last night to tinker with it until the IIS was successfully set up, so I won’t say nonsense.
PS: My system is Windows 8.1 x64, so I come with iis8.5, and the downloaded file is also x64.
No.1: Download the file
Nodejs http://www.nodejs.org/download/
iisnode https://github.com/tjanczuk/iisnode/wiki/iisnode-releases
IIS URL Rewrite http://www.iis.net/downloads/microsoft/url-rewrite
No.2: Installation
OK, the file is downloaded and the next step is to install it. However, during the installation process of win8.1, the msi installation package had an error with the error code 2503. I searched for it for a long time but I didn't know the reason. However, there is a solution online.
Solution: http://jingyan.baidu.com/article/a501d80cec07daec630f5e18.html
The simple meaning is to run CMD as an administrator, then locate your *.msi folder and enter the program name (*.msi) into the CMD and install it.
During the installation process, nodejs needs to select a folder, and the others can be handled directly next. Of course, on the premise that you agree to the agreement.
No.3: Configuration
After the 3 files are installed, run CMD as an administrator, enter node -v and will appear nodejs version, and enter nmp-v and will appear nmp version, (I don’t know what nmp is doing, contact it on the first day).
The version number appears, which means that you are half successful. Now start configuring the environment. //www.VeVB.COM/article/50260.htm This is what I learned from, for beginners.
Navigate to the nodejs folder and enter the following command (one line at a time, I only used these two commands.)
Copy the code as follows: npm install express -g npm install jade -g
At this point, the nodejs environment has been done, and the rest is to tinker with iis.
No.4: Flirting with IIS
I won’t say if I open iis like this. I will enable it myself. I don’t know how to use Baidu. Here are a few tutorial addresses:
//www.VeVB.COM/os/Windows8/85544.html
I checked all IIS selections. Of course, many are useless.
Next, let’s look at the image operation process:
OK, the iis mapping has been completed, and the next step is to create a small test page.
Find a folder as the root directory of the website: Create a serve folder and put a js file name and file contents as:
The code copy is as follows: var http = require('http'); http.createServer(function (req, res) {
res.writeHead(200, {
'Content-Type': 'text/html'
});
res.end('Hello, world!');
}).listen(process.env.PORT);
Then use the browser to access the file in the test website you created. My is http://127.0.0.1/serve/s.js
You can see that a classic hello world is output.
I have just started to contact nodejs, please don’t touch it, and don’t worship newbies.