ada-zheng

Linux安装Node.js(源码编译安装)

环境:
Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic i686)
下载Node.js安装包,请参考网址:http://nodejs.org/download/

这里选择源码包安装方式,安装过程如下:

登陆到Linux终端,进入/usr/local/src目录,如下:
root@ubuntu:~# cd /usr/local/src/

下载nodejs安装包:

#wget http://nodejs.org/dist/v0.12.0/node-v0.12.0.tar.gz


2,解压文件并安装

#  tar xvf node-v0.12.0.tar.gz 
#  cd node-v0.10.17 
#  ./configure 
# make 
# make install 
# cp /usr/local/bin/node /usr/sbin/ 
查看当前安装的Node的版本 # node -v v0.12.0

hello.js里写console.log("hello");


另外的一个实例:WebServer

这个简单Node 编写的 Web服务器,为每个请求响应返回“Hello World”。
	var http = require(\'http\');

	http.createServer(function (req, res) {
	  res.writeHead(200, {\'Content-Type\': \'text/plain\'});
	  res.end(\'Hello World\n\');
	}).listen(1337);
	console.log(\'Server running at  port 1337 \');
要运行服务器,将代码编写到文件example.js 并执行 node 程序命令行:

Server running at http://127.0.0.1:1337/

分类:

技术点:

相关文章:

  • 2022-01-16
  • 2021-07-09
  • 2021-10-06
猜你喜欢
  • 2021-12-03
  • 2021-12-11
  • 2021-04-05
  • 2021-12-01
  • 2021-12-25
相关资源
相似解决方案