If you want to install Node. js on Mac, Ubuntu, Windows, and Centos, you may not have any friends. I have sorted out some articles. If you need them, refer to them.
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
The Code is as follows:
Git clone git: // github.com/ry/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:
The Code is 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
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:
The Code is as follows:
Git clone git: // github.com/ry/node.git
Cd node
./Configure
Make
Sudo make install
Centos
The Code is 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 whether the installation is correct:
The Code is as follows:
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 /\');
Use node to run this code
The Code is as follows:
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.