Address: http://www.ooso.net/archives/589
Reference address: http://cnodejs.org/blog? P = 2080
The following describes how to install node. js on Mac, Ubuntu, centos, and Windows respectively.
Mac
On Mac, if you like to use homebrew, you can use only one line to install it:
Brew install Node
Otherwise, you can only manually install it as follows:
-
- Install xcode
-
- Install git
- Run the following command line to compile node. js
Git clone git:// Github.com/joyent/node.git
CD Node
./Configure
Make
Sudo make install
Ubuntu
- Install dependency packages
Sudo Apt - Get Install g ++ Curl libssl - Dev apache2 - Utils
Sudo Apt - Get Install git - Core
- Run the following command line:
Git clone git:// Github.com/joyent/node.git
CD Node
./Configure
Make
Sudo make install
Windows
To install node with cygwin, follow these steps:
-
- Install cygwin
-
- Run setup.exe in the cygwindirectory to install the package in the following list.
- Devel → OpenSSL
- Devel → G ++-gcc
- Devel → make
- Python → Python
- Devel → git
-
- Run cygwin
- Run the following command line:
Git clone git:// Github.com/joyent/node.git
CD Node
./Configure
Make
Sudo make install
Centos
Yum install gcc - C ++ OpenSSL - Devel
Wget -- No - Check - Certificate https : // Github.com/joyent/node/tarball/v0.3.3
Tar - Xzvf ry - Node - V0 . 3.3 - 0 - G57544ba . Tar . GZ
CD ry - Node - V0 . 3.3 - 0 - G57544bac1
./ Configure
Make
Make install
Hello node. JS!
Write a small segmentProgramFor example, hello_node.js to verify whether the installation is correct:
VaR HTTP = Require ( 'Http' );
HTTP . Createserver ( Function ( REQ , Res ) {
Res . Writehead ( 200 , { 'Content-type' : 'Text/plain' });
Res . End ( 'Hello node. jsn' );
}). Listen ( 8124 , "127.0.0.1" );
Console . Log ( 'Server running at http: // 127.0.0.1: 8124 /' );
Run this section with NodeCode
node hello_node . JS
server running at http : // 127.0.0.1: 8124/
Now, open http: // 127.0.0.1: 8124/in a browser, and you should be able to see good news.
End