Node.js学习

Node.js CentOS安装与HTTP服务器搭建教程

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.

 

后续学习中。。。。

 

转载于:https://www.cnblogs.com/cmasap/articles/2867383.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值