With the latest version of Magento, Magento 2.4 removing the MySQL search capability and forcing the use of Elasticsearch 7.x, many users may be frantically searching for the latest guide to install Elasticsearch in your server.
As most of the guides around the net are either outdated or may not work well in a CentOS 7 environment with cPanel/WHM installed, I hope this installation guide will be helpful to those of you running CentOS 7. You will need root access to follow this guide.
Firstly, create a yum repository in your server for Elasticsearch 7.x:-
Add the following content to the file:-
[elasticsearch] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=0 autorefresh=1 type=rpm-md
Then, run the Elasticsearch installation:-
yum -y install --enablerepo=elasticsearch elasticsearch
Once the installation is complete, modify the file below:-
Add this to any new line in the file above to reference a temporary directory:-
Create the temporary directory referenced above and set the appropriate file permissions:-
mkdir /usr/share/elasticsearch/tmp chmod 777 /usr/share/elasticsearch/tmp
Make sure Elasticsearch will be started automatically whenever the server reboots:-
/bin/systemctl daemon-reload /bin/systemctl enable elasticsearch.service
/bin/systemctl start elasticsearch.service