刚开始接触nodejs,先记录一下最开始用node输出一个很简单的界面
在远程服务器上先创建一个js文件 helloworld.js
[root@towrabbit nodejsLearn]# vi helloworld.js文件内容如下(需要通过按i键来进行编辑修改)
console.log('哈罗word');
var http = require('http');
http.createServer(function(request,response){
response.writeHead(200,{'Content-Type':'html'});
response.write(''+
''+
'
'+''+
'
兔子城堡'+''+
'
哈哈哈啰我的'+'');
response.end();
}).listen(8888);
console.log('server running at http://xxx.xxx.xxx:8888/');
编辑完毕之后输入esc推出编辑模式并输入:wq来保存文档
之后在node上运行helloworld.js文件
[root@towrabbit nodejsLearn]# node helloworld.js最后在服务器端输出
在客户端浏览器输出
node.js输出一个超级简单的页面