Elasticsearch is a powerful open-source analytics and search engine. It allows you to store, search, and analyze large volumes of data quickly and in near real-time. In this guide, we will go through the steps to install Elasticsearch 7 on Ubuntu 22.04/24.04, enabling you to leverage it for your projects, such as Magento 2.
Easy Elasticsearch 7 Installation on Ubuntu 22.04/24.04 LTS
Step 1. Install OpenJDK
In order for Elasticsearch to work, you need to install OpenJDK, if it is already available, skip this step.
sudo apt install openjdk-11-jdk -y
Step 2. Add Elasticsearch PGP key
Elasticsearch Ubuntu packages are registered with PGP key D88E42B4, you can view at https://pgp.mit.edu with authentication key: 4609 5ACC 8548 582C 1A26 99A9 D27D 666C D88E 42B4
Download and add the key with the command below:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
Next, add the Elasticsearch repository to the path: /etc/apt/sources.list.d/elastic-7.x.list
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
Step 3. Installing from the APT repository
You may need to install the apt-transport-https
the package on Debian before continuing:
sudo apt-get install apt-transport-https
Step 4. Install Elasticsearch
sudo apt-get update && sudo apt-get install elasticsearch -y
Step 5. Config Elasticsearch
Next, open the file elasticsearch.yml
, and find the line network.host
delete the comment (# Uncomment) and change the default IP 192.168.0.1 to localhost as shown below.
sudo nano /etc/elasticsearch/elasticsearch.yml
Press Ctrl + X
and select Y
to save the config and start elasticsearch.
sudo systemctl start elasticsearch.service
To enable Elasticsearch to start with the Ubuntu system run the command below
sudo systemctl enable elasticsearch.service
If you just change the config, it can be reloaded without restart
sudo systemctl daemon-reload
To check Elasticsearch active status
sudo systemctl status elasticsearch
Step 6. Test Elasticsearch ready to work
In step 5 we configure network.host
to be localhost, so you can open a browser and run URL: http://localhost:9200 to test:
or use the command below
curl -X GET http://localhost:9200
After completing the steps, you have successfully installed Elasticsearch 7 on Ubuntu. Continue exploring and leveraging Elasticsearch’s powerful search and data analysis capabilities.