CentOS编译安装nodejs

1. 从node.js官网下载最新版的node.js安装包,node.tar.gz

    wget https://nodejs.org/dist/v4.3.1/node-v4.3.1.tar.gz
    (如果没有wget命令需要先安装wget  yum -y install wget)

2. 如果没有g++需要

    yum -y install gcc-c++

2. 更新centos上的python

    yum -y update python

3. 解压

    tar zxvf node.tar.gz

4. 编译安装

    ./configure

    make && make install

5. 测试node命令

    node

6. hello,world程序

    touch helloWorld.js

    vi helloWorld.js

        var http = require('http');

        http.createServer(function(res, req){

            res.writeHead(200, {

                'Content-Type': 'text/plain'

            });

            res.end('Hello, world!');

        });

    node helloWorld.js

原文地址:https://www.cnblogs.com/liqipeng/p/4584799.html