蜀山兀,架构出

Node.js - 第一步

2017-05-24  本文已影响0人  Standstill
(开发环境均在linux上进行,window用户请自行寻找环境安装方法)

安装部署

  1. 获取安装包:wget https://npm.taobao.org/mirrors/node/v6.10.3/node-v6.10.3-linux-x64.tar.xz
  2. 解压安装包:tar -xzvf node-v6.10.3-linux-x64.tar.xz -C /usr/local
  3. 编辑/etc/profile添加环境变量,并通过source /etc/profile更新环境变量
export NODE_HOME=/usr/local/node-v6.10.3-linux-x64
export PATH=$NODE_HOME/bin:$PATH
  1. 创建helloworld.js
var http = require('http');
http.createServer(function(req,res){
    res.writeHead(200 , {'Content-Type' : 'text/plain'});
    res.end('Hello World!');
}).listen(3000);
  1. node helloworld.js
  2. 浏览器访问:http://{ip地址}:3000
参考自:《Node.js实战》 - Mike Cantlon 等
上一篇 下一篇
Node.js 优劣 Node.js 编程基础
上一篇 下一篇

猜你喜欢

热点阅读