How to Install ElasticSearch 7 on cPanel


How to Install ElasticSearch 7 on cPanel

You are here:

ElasticSearch is one of the most useful tools for getting fast search working on your site. It is essential on E-commerce platforms like Magento and fortunately it only takes a few minutes to get installed.

This guide is written for AlmaLinux 8 so other distros may need a couple of tweaks

Installing Java and ElasticSearch

The first step to installing ElasticSearch will be to get Java running on your server. 

					yum install java

This will get you the latest version of OpenJDK from the default repositories, and will work fine with ElasticSearch 7. 

Next we will need to setup the repository for ElasticSearch. 

Download the public signing key:

					rpm --import

Then create /etc/yum.repos.d/elasticsearch.repo and add the following:

name=Elasticsearch repository for 7.x packages

This will then allow you to install and update ElasticSearch using yum

					yum install elasticsearch

Before you start...

There are a couple of settings that will need to be changed in order to get Elasticsearch working properly on a cPanel install. 

The first is to configure your Java temp directory. This can be done by editing the file /etc/elasticsearch/jvm.options


It is also highly recommended to reduce swap usage to encourage Elasticsearch to use RAM rather than excessively using swap space.

					sysctl -w vm.swappiness=1 >> /etc/sysctl.conf
sysctl -p

That should be it! You are now ready to begin using Elasticsearch, simply enable the service so it begins on reboots and start it.

					systemctl enable elasticsearch
systemctl start elasticsearch

Verify it is working

You can check your Elasticsearch install has started correctly by viewing the logs at /var/log/elasticsearch/elasticsearch.log or by querying it

					curl -X GET "localhost:9200/?pretty"

This should give the following output

  "name" : "",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "WlokuA-8SMiUAM9AUeqhTw",
  "version" : {
    "number" : "7.17.4",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "79878662c54c886ae89206c685d9f1051a9d6411",
    "build_date" : "2022-05-18T18:04:20.964345128Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  "tagline" : "You Know, for Search"

Table of Contents