1. Install nodejs
① From the official website https://nodejs.org/en/download Download node-v8.11.3-linux-x64.tar.xz
②Decompress tar -xvf node-v8.11.3-linux-x64.tar.xz /opt
③Set the environment variable vi /etc/profile, add or modify the following two lines
copyexport NODEJS_HOME=/opt/nodejs/node-v8.11.3-linux-x64 export PATH=$PATH:$NODEJS_HOME/bin
④ Use source /etc.profile to make environment variables take effect
2. Modify elasticsearch.yml configuration
①Enter the config directory under the Elasticsearch installation directory and modify the elasticsearch.yml file. Add the following code at the end of the file code, then remove the comment from network.host:192.168.0.1 and change it to network.host:0.0.0.0.
copy# If the HTTP port is enabled, this property specifies whether cross-origin REST requests are allowed. http.cors.enabled: true # If the value of http.cors.enabled is true, this property specifies where REST requests are allowed to come from. http.cors.allow-origin: "*"
②elasticsearch service configuration properties
https://www.ibm.com/docs/zh/bpm/8.5.6?topic=service-elasticsearch-configuration-properties
3. Install elasticsearch-head
①From the github official website https://github.com/mobz/elasticsearch-head Download elasticsearch-head-master.zip
②Unzip unzip elasticsearch-head-master.zip -d /opt
4. Install grunt
grunt is a convenient construction tool that can be used for packaging, compression, testing, execution, etc. Confirm that it is currently in the elasticsearch-head-master directory.
① Execute npm install -g grunt-cli, if the installation is unsuccessful, replace the image with a domestic one, and execute
copynpm install -g grunt-cli --registry=https://registry.npm.taobao.org.
② Then execute
copynpm install -g grunt-cli --registry=https://registry.npm.taobao.org
If there is an error phantomjs-prebuilt@2.1.16 install:node install.js error, execute the command
copynpm install phantomjs-prebuilt@2.1.16 --ignore-scripts
③Enter the elasticsearch-head directory, modify the Gruntfile.js file, and add hostname:'*'.
④Finally execute grunt server (npm run start & run in the background).
⑤ Now you can open http://ip:9100/.
5.Fatal error
Port 9100 is already in use by another process. Solution
copy#View the process id occupying the port lsof -i:9100 #kill process kill -9 4852
6. Extension:
NPM (node package manager) is a package management tool for node. Because node is a light-core platform, although it provides a series of built-in modules, it is far from enough to meet the needs of developers, so the concept of package (package) appeared. NPM can be said to be Node's open module registration and management system, an ecosystem or community, or it can be said to be Node's default module manager, which is a command-line software used to install and manage Node modules. Its official community address is https://www.npmjs.com/ , and its corresponding domestic accelerated image is https://npm.taobao.org/.
1. Decompression software
copytar -zxvf /home/node/Desktop/elasticsearch-head-master.tar.gz -C /opt/ tar -zxvf /home/node/Desktop/node.tar.gz -C /opt/
2. Configure environment variables
copyvim /etc/profile NODE_HOME=/opt/node-v14.5.0-linux-x64 NODE_PATH=$NODE_HOME/lib/node_modules PATH=$NODE_HOME/bin:$NODE_PATH:$PATH #reload environment variables source /etc/profile #View the location of the global plugin installation npm root -g #show /opt/node-v14.5.0-linux-x64/lib/node_modules
3. Check the version of node and npm
copynode -v npm -v
4. The package installation of npm is divided into local installation (local) and global installation (global).
copy# local installation npm install grunt #If -g is not added, the default is to use local installation, and npm will download and install the module components in the current path where the command is executed. # Global installation npm install -g grunt-cli #Add -g to use global installation, and npm will install it under the set global path. It is convenient for unified management.
5. Configure the global plug-in file storage directory
Note: The local nodejs installation path is: /opt/nodeJs, first create 2 empty folders in the installation directory
copycd /opt/nodeJs mkdir -p node_global mkdir -p node_cache #Then execute the following command: npm config set prefix "/opt/nodeJs/node_global" npm config set cache "/opt/nodeJs/node_cache"
6. Install the global plugin
The advantage of installing global plugins is that they can be shared by all users and all projects.
copy#First check the location of the installation storage directory of the global plugin: npm root -g #npm install plugin globally # The -g parameter means global installation npm install module_name -g Check npm List of installed global plugins: npm list -g or npm ls -g
7. Specify mirror installation
copynpm install --registry=https://registry.npm.taobao.org npm install grunt-cli --registry=https://registry.npm.taobao.org
8. The zip file downloaded from github is further installed via npm
copyfile name: aa-master.zip Unzip to the specified path: unzip aa-master.zip -d /opt/ Enter the specified path: cd /opt/aa-master run: npm install
9. Establish a soft connection
copyln -s /opt/node-v14.5.0-linux-x64/bin/npm /usr/local/bin/npm ln -s /opt/node-v14.5.0-linux-x64/bin/node /usr/local/bin/node
10. The difference between global installation and specific installation
copynpm install --global gulp-cli #Installing globally will require root privileges npm install gulp --save-dev #Install in specific project dependencies, no privileges required as we won't be changing any system related directories.
11.Fatal error: Port 9100 is already in use by another process. Solution
copy#View the process id occupying the port lsof -i:9100 #kill process kill -9 4852
12. Compress files
copytar -zcf elasticsearch-head-master.tar.gz ./elasticsearch-head-master/ tar -zcf nodeJs.tar.gz ./nodeJs/ tar -zcf node-v14.5.0-linux-x64.tar.gz ./node-v14.5.0-linux-x64/
13. Unzip command
copytar -zxvf /home/node/Desktop/nodeJs.tar.gz -C /opt/ tar -zxvf /home/node/Desktop/node-v14.5.0-linux-x64.tar.gz -C /opt/ tar -zxvf /home/node/Desktop/elasticsearch-head-master.tar.gz -C /opt/