CentOS系统环境如图:
安装开始:
wget http://nodejs.org/dist/v0.10.15/node-v0.10.15.tar.gz
#若提示wget command not found,可直接复制此链接下载安装包,后面的步骤一样。
tar zxvf node-v0.10.15.tar.gz
cd node-v0.10.15
./configure
make && make install
配置的时候出现如下错误:
fpu = 'vfpv3' if armv7 else 'vfpv2'
引起此错误的原因是Python的版本过低,升级到2.7即可:
wget -c http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
#同上
tar jxvf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure
make && make install
python2.7便安装成功,路径:/usr/local/lib/python2.7。
重复步骤一即可,安装成功。查看node.js的版本信息:
写个示例代码测试node.js能否正常运行:
var http = require('http');
http.createServer(function(req,res){
res.end('hello');
}).listen(3000);
console.log('Server is running at http://localhost:3000/')
在浏览器端打开 http://localhost:3000,可以看到页面打印出了"hello",说明node.js环境安装成功。
「真诚赞赏,手留余香」

- 本站文章除注明转载外,均为本站原创
- 欢迎任何形式的转载,但请务必注明出处,尊重他人劳动
- 转载请注明:文章转载自:Marser [https://www.marser.cn]
- 本文标题:centos安装node.js
- 本文固定链接: https://www.marser.cnarticle/31.html