Step by step, we will teach you how to build the node. js service under win7 (to play with JavaScript on the server side, this is not a front-end JS plug-in)

Source: Internet
Author: User
Tags install node nameserver

What is node. js? Return the server-side JavaScript? In this articleArticleIf you do not want to explain it, you can search and find out that server-side JS is not a new technology, but a recent node. the popularity of JS broke out. I will explain what node is in a later article. JS. Here is just a pure setup, even the environment is not available, but what server-side JS is playing, everything has become a floating cloud, let's first build an environment, enter a "hello World" page.

Right. If you build Windows 7, you only need to follow me step by step. It's okay. You don't need to know too much details. It's not something we need to care about now, our primary goal now is to set up the environment, otherwise there will be no further steps.

Step 1. Download
Node. JS is to be installed under cygwin in windows. Go to the cygwin website to download cygwin InstallationProgram.

Cygwin Website: http://cygwin.com/

Direct: http://cygwin.com/setup.exe

Step 2. Install
To install the cygwin program, you only need to perform the next step.

On the choose a download Source Page, select "Install from Internet ".

On the select your Internet connection page, select> Direct Connect

Select "-" On the choose a download site interface and select the downloaded image,We recommend that you use the Japanese website ending with. JP, which is faster.

Note:: If you are installing it for the first time, a warning message may pop up, regardless of whether you care about it, click OK.

Step 3. Select the installation component
Note:: Because there are many components, we recommend that you search for them.Click the name to select the image. A small square is displayed after the image is selected, with X (Cross) representing the selected image..

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:: Install all. You only need to 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

After the next step, you will be prompted that many dependent components need to be installed. Simply follow the next step.
Note:: Because all components are downloaded online, it may take a long time to wait.

Step 4. Run ash.exe

After the installation is complete, the icon is generated on the desktop (if you select the icon generated on the desktop ),Note not to run this icon!

Open the folder and go to the C: \ cygwin \ bin \ directory. This is the default installation directory. If you have modified the installation directory, go to the bin directory under cygwin's installation directory.

Run ash.exe

Execute the./rebaseall-V command in the pop-up command window.

After the command is executed, execute exit to exit ash.

Step 5. Download and install node. js

Run the cygwin program on the desktop.

Enter the wget http://nodejs.org/dist/node-v0.4.7.tar.gz in the Command window and press Enter.

Note:: I am writing this article about node. the latest version of JS is node-v0.4.7, http://nodejs.org/dist/node-v0.4.7.tar.gz is node. JS, you can go to node when reading this article. the JS website can be replaced with the latest download path.

Node. js Website: http://nodejs.org/

Enter the tar xf node-v0.4.7.tar.gz in the Command window, node-v0.4.7.tar.gz for your own version.

Enter the CD node-v0.4.7 in the Command window and press Enter.

Enter./configure in the Command window and press Enter.

Enter make in the Command window and press Enter.

Enter make install in the Command window and press Enter.

OK. Now you have installed node. js.

Enter node -- version in the Command window and press enter to check your node. js version.

Step 6. Set DNS
Open the folder and go to the C: \ cygwin \ etc \ folder.

Manually create the resolv. conf file.

Use NotePad to open the newly created resolv. conf file and add the following

Nameserver 8.8.8.8
Nameserver 8.8.4.4
Save and close.

Step end. Test whether node. js can be run

Now that you have completed the setup, but you don't know if it can run correctly, let's write an example file to test it.

Create example. js in the C: \ cygwin \ directory

Input
VaR HTTP = require ('http ');

HTTP. createserver (function (request, response ){
Response. writehead (200, {'content-type': 'text/html '});
Response. End ('<B> Hello World </B> ');
}). Listen (8888 );

Console. Log ('server running at http: // 127.0.0.1: 8888 /');

Save (Note: Save As UTF-8 format, otherwise a syntax error will be reported).

Run cygwin and enter node/example. js in the Command window and press Enter.

Have you seen server running at http: // 127.0.0.1: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.