Elasticsearch is an incredibly powerful search engine in which data can be stored and recalled in real-time. Because of the speed and reliability of Elasticsearch, it is highly recommended if you are searching through large amounts of data on a regular basis. Thanks to projects like ElasticPress, it can also be used easily within WordPress as a replacement for the default search. In this article, we will show you how to install Elasticsearch on InMotion Hosting or any other CentOS/Red Hat based system.
Note: You will need to have a VPS or dedicated server with root access to be able to install Elasticsearch.
Installing Elasticsearch from the repository
The easiest way to install Elasticsearch is from their repositories. Doing so is not only simple to install, but will also allow you to easily keep Elasticsearch updated.
First, SSH into your server as root.
Now, as Elasticsearch depends on Java to run, we will need to begin installing Java on the server. To do so, first begin by updating the repositories:
Now, install Java:
yum install java
If all goes well, Java should now be installed on the server and you are ready to begin installing Elasticsearch.
Next, we will add the Elasticsearch repository to the server. Begin by adding the public signing key:
rpm –import https://packages.elasticsearch.org/GPG-KEY-elasticsearch
Now, we need to add the actual repository. Use the following to open a text editor and create a new file holding the Elasticsearch repository:
Within the text editor, paste in the following:
[elasticsearch-6.x] name=Elasticsearch repository for 6.x packages
Once entered, press Ctrl+X and then the Y key to save changes.
Now that the repository is set up, Elasticsearch is ready to install. To do so, enter the following:
yum install elasticsearch
Elasticsearch will now be installed. Once complete, if you want it to automatically start when the system is booted, follow the next section on setting ElasticSearch as a system service.
Setting ElasticSearch as a system service
If you want Elasticsearch to automatically when the system is started, enter the following command to see it as a system service:
chkconfig –add elasticsearch
If you’re using Systemd, enter the following command instead:
systemctl enable elasticsearch
Elasticsearch with WordPress
In addition to Elasticsearch’s many use cases, individuals can easily integrate Elasticsearch with WordPress. For more information on doing so, take a look at our article on Elasticsearch in WordPress using ElasticPress.