npm config set prefix "D:\nodejs\node_global"
博主截下自己的安装目录
这个是node_global目录
添加环境变量 path 加上 D:\nodejs\node_global(这里的路径和上面的要对应,就怕小白乱复制) 方便后面调用grunt
下载Elasticsearch 5.1.1
下载地址:https://www.elastic.co/downloads/elasticsearch
zip和tar格式是各种系统都通用的,解压之后启动Elasticsearch即可。
npm install -g grunt-cli
-g代表全局安装。安装路径为D:\nodejs\node_global(你上面设置的全局路径),安装完成后检查一下:
先查看你的node_global目录下面有没有grunt.cmd命令
如果有但是提示grunt不是可运行的命令,自己设置下path变量
这些是Grunt file.js中引用的,分别下载。ok
npm install grunt-contrib-copy
npm install grunt-contrib-concat
npm install grunt-contrib-uglify
npm install grunt-css
把head插件的源码Git clone下来:
git clone git://github.com/mobz/elasticsearch-head.git没装git的自己去下载
https://github.com/mobz/elasticsearch-head
由于head的代码还是2.6版本的,直接执行有很多限制,比如无法跨机器访问。因此需要用户修改两个地方:
目录:head/Gruntfile.js:
connect: { server: { options: { port: 9100, hostname: '*', base: '.', keepalive: true } } }增加hostname属性,设置为*
目录:head/_site/app.js
修改head的连接地址:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";把localhost修改成你es的服务器地址,如:
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://10.10.10.10:9200";修改一下es使用的参数。编辑config/elasticsearch.yml:
# 换个集群的名字,免得跟别人的集群混在一起 cluster.name: es-5.0-test # 换个节点名字 node.name: node-101 # 修改一下ES的监听地址,这样别的机器也可以访问 network.host: 0.0.0.0 # 默认的就好 http.port: 9200 # 增加新的参数,这样head插件可以访问es http.cors.enabled: true http.cors.allow-origin: "*"
注意,设置参数的时候:后面要有空格!
开启ES-5.0.0:
D:\ElasticSearch-5.0.0\bin\elasticsearch.bat然后在head源码目录中,执行npm install 下载的包:
npm install初次运行安装可能会报警告或错误。可以重新运行一次npm install。
最后,在head源代码目录下启动nodejs:
grunt server效果如图:
这个时候,访问 http://localhost:9100 就可以访问head插件了:有问题留言,博主可能会忘了什么没写上去
楼主的Github,很多是共享项目
GitHub:https://github.com/JoeyBling
