1、安装phantomjs(因为入坑多写一步,此步骤可省掉)html
1.下载phantomjsnode
安装npm的时候会依赖phantomjs 因此咱们先安装phantomjslinux
phantomjs 下载地址:http://phantomjs.org/download.htmlgit
能够复制下载地址经过命令来下载,以下github
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2npm
2.解压安装包vim
① yum install bzip2跨域
② bzip2 -d phantomjs-2.1.1-linux-x86_64.tar.bz2浏览器
③ tar -xvf phantomjs-2.1.1-linux-x86_64.tarcors
3.安装(因为个人解压目录在 /home/tools/phantomjs-2.1.1-linux-x86_64,因此后面就直接写绝对路径了)
① 将可执行文件放入系统路径
ln -s /home/tools/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
② 安装依赖——fontconfig和freetype
yum install fontconfig freetype2
③ 配置环境变量
vim /etc/profile
export PHANTOMJS=/home/tools/phantomjs-2.1.1-linux-x86_64
export PATH=$PATH:$PHANTOMJS/bin
保存后执行:source /etc/profile
④ 测试 执行以下命令会显示phantomjs的版本
phantomjs -v
2、安装node
1.检测node环境 (若是存在能够直接看第三步)
node -v
2.安装 node
① 下载nodejs 下载地址:https://nodejs.org/en/download/
wget https://nodejs.org/dist/v8.11.2/node-v8.11.2-linux-x64.tar.xz
② 解压 node
xz -d node-v8.11.2-linux-x64.tar.xz
tar -xvf node-v8.11.2-linux-x64.tar
③ 创建软链接,变为全局
ln -s /home/tools/node/node-v8.11.2-linux-x64/bin/node /usr/local/bin/node
ln -s /home/tools/node/node-v8.11.2-linux-x64/bin/npm /usr/local/bin/npm
④ 安装 npm,grunt
npm install -g cnpm
npm install -g grunt-cli
⑤ 配置环境变量
vim /etc/profile
在文件最后添加
export NODE_HOME=/home/tools/node/node-v8.11.2-linux-x64
export PATH=$PATH:$NODE_HOME/bin
保存后执行 source /etc/profile
⑥ 测试
node -v
npm -v
grunt -version
3、安装 elasticsearch-head
elasticsearch-head 的开源地址:https://github.com/mobz/elasticsearch-head
1.下载并解压
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
unzip master.zip //若是没有unzip这个命令 能够经过 yum install unzip 进行安装
2.安装
进入解压好的目录 cd elasticsearch-head-master 执行 npm install
不少教程都这么讲的,此时我入坑了,会出现如下问题
将 npm install 改成 npm install -g 便可
测试:在elasticsearch-head-master 目录下启动 nodejs : grunt server
经过浏览器访问:http://ip:9100 以下
4、跨域问题处理
1.问题说明
上诉步骤执行完之后启动elasticsearch服务会发现 elasticsearch-head插件链接不上elasticsearch服务,此时可查看浏览器控制台有跨域的错误出现
2.问题处理
编辑 elasticsearch 服务 config/elasticsearch.yml
在文件的最后加入
http.cors.enabled: true
http.cors.allow-origin: "*"
保存文件,从启elasticsearch服务,再次链接,便可成功,如图