Mac
Under a Mac, if you like to use homebrew, then just use one line to install it:
Brew Install node
Otherwise, you can only consider manual installation, as follows:
Install Xcode
Install Git
Run the following command line to compile Node.js
Copy Code code as follows:
git clone git://github.com/ry/node.git
CD node
./configure
Make
sudo make install
Ubuntu
Install Dependency Pack
sudo apt-get install g++ Curl Libssl-dev apache2-utils
sudo apt-get install Git-core
Run the following command line:
Copy Code code as follows:
git clone git://github.com/ry/node.git
CD node
./configure
Make
sudo make install
Windows
To install node with Cygwin, follow these steps:
Install Cygwin
In the Cygwin directory, run setup.exe install the packages in the following list
Devel→openssl
devel→g++-gcc
Devel→make
Python→python
Devel→git
Run Cygwin
Run the following command line:
Copy Code code as follows:
git clone git://github.com/ry/node.git
CD node
./configure
Make
sudo make install
Centos
Copy Code code as follows:
Yum Install gcc-c++ Openssl-devel
wget--no-check-certificate https://github.com/ry/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 program such as hello_node.js to verify that the installation is correct:
Copy Code code as follows:
var http = require (\ ' http\ ');
Http.createserver (function (req, res) {
Res.writehead ({\ ' 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/\ ');
Use node to run this piece of code
Copy Code code as follows:
Node Hello_node.js
Server running at http://127.0.0.1:8124/
Now, with the browser open http://127.0.0.1:8124/, you should be able to see a piece of good news.