I. Preparatory work
1. Installing GCC
yum install gcc-c++ openssl-devel
2. Upgrade Python
Upgrade Step: http://blog.51cto.com/qiangsh/1979284
Ii. compiling and installing node. js
wget http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gztar -xzvf node-v0.10.29.tar.gz cd node-v0.10.29/ ./configure make sudo make install
Test:
node --versionv0.10.29
The following error occurred during the installation:
ImportError: No module named bz2make[1]: *** [/data/package/node-v0.10.29/out/Release/obj/gen/libraries.cc] Error 1make[1]: Leaving directory `/data/package/node-v0.10.29/out‘make: *** [node] Error 2
Workaround:
yum install bzip2-devel然后需要重新编译一下python,之后再import bz2就不会提示错误了。
Three. Test node. js
The first program is the Hello World, find a free directory
vi hello_world.js plaster入以下内容:var http = require(‘http‘); http.createServer(function (req, res) { res.writeHead(200, {‘Content-Type‘: ‘text/plain‘}); res.end(‘Hello Node.js\n‘); }).listen(8888, "127.0.0.1"); console.log(‘Server running at http://127.0.0.1:8888/‘); 然后编译,当前目录下输入:node hello_world.js
Output server running at ... Represents a successful compilation. (if prompted Commad:node:not found, then the second compilation is not successful, you can compile the times, notice whether there is an error, or can not find the node command, configure a soft connection: Ln-s/usr/local/bin/node/usr/bin/ node)
Then in the browser input http://127.0.0.1:8888, the browser prints out Hello node. js
Iv. Follow-up work
Installing NPM
NPM is a NODEJS package management and Distribution tool, has become the unofficial Release Node module (package) standard, with NPM, you can quickly find a specific service to use the package, to download, install and manage the installed packages
curl http://npmjs.org/install.sh | sh
Tips...... It worked, NPM installation is successful!
Then install the Express module
npm install express
Well, the installation is complete and node. js can be developed!
CENTOS6 Installing and installing node. js