一、下载安装包
1,下载elasticsearch-head
https://github.com/mobz/elasticsearch-head
2,下载node.js二进制版;安装方式见 【centos6.5源码编译安装nodejs】
https://nodejs.org/en/download/current/
二,安装grunt
安装好elasticsearch 和node.js之后 安装grunt
命令: npm install -g grunt-cli
输入“grunt”命令 验证
结果:
参考:http://blog.csdn.net/yuchen_0515/article/details/48653061
官网:http://gruntjs.com/getting-started
三、npm 安装依赖
到elasticsearch-head-master目录下,运行命令:
# npm install 建议耐心等待或者 执行npm install grunt --save-dev
安装过程中如果出现如下错误,不要管,继续往下走:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
npm ERR! Linux 2.6.32-504.el6.x86_64
npm ERR! argv "/opt/soft/node/bin/node" "/opt/soft/node/bin/npm" "install"
npm ERR! node v7.4.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! phantomjs-prebuilt@2.1.14 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the phantomjs-prebuilt@2.1.14 install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the phantomjs-prebuilt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs phantomjs-prebuilt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls phantomjs-prebuilt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/elk/elasticsearch-head-master/npm-debug.log
如果速度较慢或者安装失败,可以使用国内镜像:(执行这个命令成功后往下走还是会报错)
npm install -g cnpm --registry=https://registry.npm.taobao.org
四、修改Elasticsearch配置文件
编辑elasticsearch-5.1.1/config/elasticsearch.yml,加入以下内容:
http.cors.enabled: true
http.cors.allow-origin: "*"
五、修改Gruntfile.js
打开elasticsearch-head-master/Gruntfile.js,找到下面connect属性,新增hostname: ‘0.0.0.0’:
connect: {
server: {
options: {
hostname: '0.0.0.0',
port: 9100,
base: '.',
keepalive: true
}
}
}
六、启动elasticsearch-head
在elasticsearch-head-master/目录下,运行启动命令:
# grunt server
如果报如下错误,这说明 第三步:npm 安装依赖 出了问题 重新耐心 npm install
# grunt server
grunt-cli: The grunt command line interface (v1.2.0)
Fatal error: Unable to find local grunt.
If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:
http://gruntjs.com/getting-started
访问9100端口: