---
title: "centos 安装 Node.js 0.8.5"
author: "sailinglee"
date: "2012-08-14T08:59:59Z"
tags: []
categories: ["互联网"]
slug: "centos-node-js-0-8-5"
draft: false
lastmod: "2012-08-14T09:04:06Z"
id: 1631037
url: "https://sailinglee.iteye.com/blog/1631037"
---

### centos 安装 Node.js 0.8.5

node.js 0.8.5的安装，需要python 2.7，大部分安装失败，都是因为python版本过低所致。安装之前，请升级python版。升级步骤[http://sailinglee.iteye.com/blog/1631033](http://sailinglee.iteye.com/blog/1631033)

 

```
[tom@MyVPS1974 ~]$ python -V
Python 2.7.3
```

 

开始安装：

 

```
wget http://nodejs.org/dist/v0.8.5/node-v0.8.5.tar.gz
tar zvxf node-v0.8.5.tar.gz
cd node-v0.8.5
./configure
make && make install
```

 

写一段小程序例如hello\_node.js来验证安装是否正确：

 

```
var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {
    'Content-Type': 'text/plain'
  });
  res.end('Hello Node.js');
}).listen(8124, "127.0.0.1");

console.log('Server running at http://127.0.0.1:8124/');
```

 

用node来运行这段代码

 

```
[tom@MyVPS1974 ~]$ node hello_node.js
Server running at http://127.0.0.1:8124/
```

现在，用浏览器打开 [http://127.0.0.1:8124/](http://127.0.0.1:8124/) ， 应该能够看到一条消息。

 

\[转自:[http://cnodejs.org/topic/501ddec0f767cc9a51bad53c](http://cnodejs.org/topic/501ddec0f767cc9a51bad53c)]