0. What is node. js?
Node. JS is a platform built on Google Chrome's JavaScript runtime. To facilitate the creation of fast and scalable applications.
Node. JS is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications.
1. Download cygwin, URL: http://cygwin.com/setup.exe
2. Install cygwin
Click Next and select "Install from Internet (network installation )"
Select the installation path, which is placed in D: \ cygwin
Select the path of the local package and decompress the downloaded file during installation. The default path is used here.
Click Next, select the network connection type, and use the direct connection method.
Click Next. We recommend that you use the Japanese website ending with. JP, which is faster.
Click Next to start Installation
If an error occurs, ignore it and press OK to continue the installation.
3. Select the component for cygwin installation.
Find the following category (with a plus sign in front)
Devel category
Gcc-G ++: C ++ Compiler
Gcc-mingw-G ++: mingw32 support headers and libraries for gcc C ++
Gcc4-g ++: G ++ subpackage
Git: fast version control system-core files
Make: the GNU version of The 'make' Utility
OpenSSL-devel: The OpenSSL Development Environment
PKG-config: a utility used to retrieve information about installed Libraries
Zlib-devel: the zlib compression/Decompression Library (Development)
Editor category
VIM: VI improved-enhanced VI Editor
Python Classification
All
Note: To install all the configurations, click the icon on the Right of python to switch to install.
Web Classification
Wget: utility to retrieve files from the WWW via HTTP and FTP
Curl: multi-protocol file transfer command-line tool
Is the choice in the devel category
One installation, one step
Download the Selected Package
At last, whether to create the desktop icon and the Start menu icon are displayed. Use the default icon and click Finish.
4. Find the binfolder under cygwin's installation folder and run ash.exe
Enter./rebaseall-V
Start resetting all
5. Download and install node. js
Run cygwin Terminal
Enter wget http://nodejs.org/dist/node-v0.4.7.tar.gzto download the file in the command line.
Enter
Enter the tar xf node-v0.4.7.tar.gz to decompress the file
Input the CD node-v0.4.7.tar.gz to change the working directory
Enter./configure Configuration
Configuration successful
Input make to compile
Start Compilation
Compilation successful. A prompt is displayed.
Enter make install to install
If the installation is successful, a prompt is also displayed.
Enter node -- vesion to view the node. js version.
If v0.4.7 is displayed, the installation is successful.
Enter exit to exit
6. Set DNS
In the installation path, manually create a file named resolv. conf under D: \ cygwin \ etc.
Enter the content
7. Test whether node. js can be run
Create example. js in UTF-8 format under the c: \ cygwin \ directory
The above code is described below:
Line 1: The module HTTP that comes with node. js needs to be assigned to the variable HTTP.
Line 3 (out of brackets): Use the HTTP module method createserver ()
Row 6: This method returns an object. This object has a method called listen (), which is used to listen to a port. Therefore, three rows (out of brackets) are returned) and six rows are created to listen to port 8888 Server
Three rows (in parentheses): An anonymous function has two parameters: one request and one response.
Line 4: when receiving the request, use the response. writeHead () function to send an http status 200 and content type of the http header (content-type)
Row 5: You can use the response. write () function to send the text "Hello World" in the http body and use the response. end () function to complete the response. Response. end (text) is used for merging.
Run Cygwin Terminal and enter node/example. js
It indicates that the server is running on port 8888.
Do not close cygwin. Open your browser and visit http: // 127.0.0.1: 8888/To see if the hello world page is displayed.
Since then, the Node. js environment has been built.
Is it very simple?
Bytes ------------------------------------------------------------------------------------------------
This article is based on the experience of many online friends, such as PHPhuaibei. Thank you.