一 下载node.js
nodejs官网下载地址https://nodejs.org/dist/
二解压node.js并配置环境变量
xz –d node-v6.9.2-linux-x64.tar.xz
tar –xvf node-v6.9.2-linux-x64.tar
mv node-v6.9.2-linux-x64 /data/PRG/node
vim /etc/profile
export NODE_HOME=/data/PRG/node
export PATH=NODE_HOME/bin
source /etc/profile
¥node –v
v6.9.2
¥npm –v
3.10.9
三 安装grunt
如果生产环境无法联网在线安装grunt,可以找一台能联网的主机配置好node,安装好grunt后将elasticsearch-head目录下的node_models打包上传
cd elasticsearch-head
npm install -g grunt --registry=https://registry.npm.taobao.org
修改head目录下的Gruntfile.js配置,head默认监听127.0.0.1
vim Gruntfile.js
hostname: '0.0.0.0',
![](https://img.haomeiwen.com/i3128853/0aed6e7429748202.png)
四 elasticsearch配置允许跨域访问
修改elasticsearch配置文件elasticsearch.yml,添加以下内容:
http.cors.enabled: true
http.cors.allow-origin: "*"
五 重启elasticsearch,并启动node
cd elasticsearch-head
前台启动:grunt server
后台启动 :nohup grunt server &exit
====================关闭head==========================
如果想关闭head插件,使用linux查找进程命令:
ps aux|grep head
结束进程:
kill 进程号
网友评论