Node.js学习

Node.js安装

Cent-OS下安装

yum install gcc-c++ openssl-devel wget --no-check-certificate https://github.com/joyent/node/tarball/v0.3.3

tar -xzvf ry-node-v0.3.3-0-g57544ba.tar.gz

cd ry-node-v0.3.3-0-g57544bac1

./configure

make

make install

安装成功后,写一个测试脚本

console("hello world");

Node name.js

测试成功,应该返回hello world.

 

下面写一个HTTP服务器,文件名为server.js

var http = require("http");

http.createServer(function (request,response) {

response.writeHead(200,{"Content-Type":"text/plain"});
response.write("Hello World");
response.end();
}).listen(8888)

开启8888端口

运行node server.js &,放在后台运行。

 

测试:192.168.1.2:8888,成功,返回hello world.

 

后续学习中。。。。

 

posted @ 2013-01-19 11:32  cmasap  阅读(126)  评论(0编辑  收藏  举报