CentOS 6.9安装配置Node.js

一、下载软件包node-v8.4.0-linux-x64.tar.xz,网址http://nodejs.cn/download/

二、关闭iptablesSELinux

三、服务器时间校对

四、解压软件包:

# yum -y install xz

# tar -xf node-v8.4.0-linux-x64.tar.xz -C /usr/local

# cd /usr/local

# ln -sv node-v8.4.0-linux-x64 node

五、配置环境变量:

# vim /etc/profile.d/node.sh

export NODE_HOME=/usr/local/node

export PATH=$PATH:$NODE_HOME/bin

export NODE_PATH=$NODE_HOME/lib/node_modules

# . /etc/profile.d/node.sh

六、查看Node.js安装版本:

# node -v

七、编写helloworld.js测试文件:

# vim /software/helloworld.js

var http = require('http');

http.createServer(function(req,res) {

res.end('helloworld...')

}).listen(8080);

console.log('服务已启动,监听端口8080......')

八、启动Node.js,查看效果:

# node /software/helloworld.js

浏览器访问192.168.1.148:8080

下面关于Node.js的内容你可能也喜欢

Node.js 的详细介绍请点这里
Node.js 的下载地址请点这里

猜你喜欢

转载自www.linuxidc.com/Linux/2017-10/147665.htm