Preparatory work
1, CentOS system upgrade Python to 2.7.3
2, Python 2.7.3 installation bz2 expansion
Please be sure to complete the above operation before you do the following, otherwise please come back, and you will encounter the following error
The code is as follows |
Copy Code |
FPU = ' Vfpv3 ' if armv7 Else ' Vfpv2 '
|
After the preparation is done, you can easily install the node.js.
The code is as follows |
Copy Code |
wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz Tar zxvf node-v0.10.26.tar.gz CD node-v0.10.26 ./configure Make Make install |
The following error is prompted when installing Nodejs:
Importerror:no module named bz2
Workaround:
The code is as follows |
Copy Code |
1. # yum Install-y bzip2* 2. # CD Python-2.7/modules/zlib #./configure Make;make Install 3. # CD python-2.7/ # python2.7 setup.py Install |
Here's a simple example to feel the power of node.js
The code is as follows |
Copy Code |
var http = require (' http '); Http.createserver (function (req,res) { Res.writehead ({' Content-type ': ' Text/plain '}); Res.end (' Hello world!n '); }). Listen (1337, ' xx.xx.xx.xx '); Console.log (' Server running at http://xx.xx.xx.xx:1337 '); |
Replace xx.xx.xx.xx with your server's IP address, save the above to Example.js, and then run
The code is as follows |
Copy Code |
# node Example.js Server running at http://xx.xx.xx.xx:1337 |
Next open your browser, enter http://xx.xx.xx.xx:1337 to see!
Here to note: If you are centos5.5 install Nodejs our Python version to be in Python 2.4 otherwise it may be wrong