Just started to contact nodejs, first record a very simple interface with node output at first
First create a js file helloworld.js on the remote server
[root@towrabbit nodejsLearn]# vi helloworld.jsThe content of the file is as follows (you need to press the i key to edit and modify)
console.log('Hello word'); var http = require('http'); http.createServer(function(request,response){ response.writeHead(200,{'Content-Type':'html'}); response.write('<!DOCTYPE html>'+ '<html>'+ '<head>'+ '<meta charset="utf-8" />'+ '<title>The Rabbit Castle</title>'+ '</head>'+ '<body>Hahaha my </body>'+ '</html>'); response.end(); }).listen(8888); console.log('server running at http://xxx.xxx.xxx:8888/');
After editing, enter esc to exit the editing mode and enter: wq to save the document
After that run the helloworld.js file on node
[root@towrabbit nodejsLearn]# node helloworld.jsFinally output on the server side
output in client browser
node.js outputs a super simple page