Summary of CentOS System installation Node.js method

Source: Internet
Author: User
Tags bz2 centos in python

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.