Magento 2.4 Installation with Elastic Search

Process of Magento 2.4 Installation with Elasticsearch

In all eCommerce websites, including the ones that are built on Magento 2 platform, the search is one of the most crucial functionalities.

An effective and efficient search functionality allows customers to easily find their desired products on an online store, which almost always results in a smooth customer experience and increased sales.

According to research, 87% of online shoppers begin their product search online and these eCommerce site searchers are 216% more likely to make a purchase than those who don’t.

Another research also revealed that eCommerce site search optimization can increase conversion rates by a whopping 43%.

And the good news is, you can easily attain such an increase in the conversion rate of your online store by incorporating ElasticSearch.

What is ElasticSearch?

ElasticSearch is an extremely powerful, open-source, search and analytics engine that is built on Apache Lucene.

When installed in eCommerce stores, especially Magento 2 based stores, it can help to map all documents very effectively to optimize the search and retrieval functionality.

Recommended: What is ElasticSearch & What are the Benefits of ElasticSearch?

And in this post, we’re going to show you the entire process of Magento 2.4 installation with ElasticSearch.

Step-by-Step Process for Magento 2.4 Installation with ElasticSearch

To install Magento 2.4 with ElasticSearch, please follow the below steps.

Step #1 – Install Apache2 on Ubuntu

To install Apache2 on Ubuntu, first, we will have to install a LAMP setup via the command line.

The Apache is basically an HTTP web server that provides various powerful features like robust media support, dynamically loadable modules, extensive integration, and more.

Now, to install Apache2 on Ubuntu, follow the below-given instructions.

  • First, we need to install Apache using the below commands:
# apt-get update

apt-get updatess

# apt-get install -y apache2

apt-get install -y apache2

  • After that, we need to allow Firewall by executing the below commands.
# ufw app list

ufw app list

# ufw allow 'Apache'

ufw allow 'Apache'

# ufw status

ufw status

As you can see in the last screenshot, the Firewall is inactive.

To enable the Firewall, execute the following command, and check the status again.

# ufw enable

ufw enable

# ufw status

ufw status

  • Lastly, we also need to check web server by using the below command.
# service apache2 status

service apache2 status

Step #2 – Install MySQL on Ubuntu

MySQL is an open-source database management system that is usually installed as a part of a technology stack such as LAMP (Linux, Apache, MySQL, PHP/Perl/Python).

To install MySQL on Ubuntu, please follow the below-given instructions.

  • First off, we need to execute the following commands to install MySQL.
# apt-get update

apt-get updateapt-get update

# apt-get install mysql-server

apt-get install mysql-server

  • Now, we need to configure the MySQL as shown below.

configure the MySQL

Next, you need to pass a three-level password validation along with the given root password.

three-level password validation

# mysql


  • After this, we now need to create a MySQL user. Please execute the following command to create a new user and give it a strong password.

mysql> CREATE USER ‘magento’@’localhost’ IDENTIFIED BY ‘magento123’;


  • Then, we need to grant this new user privileges to all database tables and power to add, modify, and delete by executing the following command.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'magento'@'localhost' WITH GRANT OPTION;




mysql> exit;
  • Now, it’s time to test the MySQL by executing the following command.
# systemctl status mysql

systemctl status mysql

Step #3 – Install PHP 7.3 on Ubuntu

  • To install PHP, execute the following commands.
# apt-get install software-properties-common

apt-get install software-properties-common

# add-apt-repository ppa:ondrej/php

add-apt-repository ppa:ondrej/php

# apt-get update

apt-get updates

# apt-get install -y php7.3

apt-get install -y php7.3

# php -v

php -v

  • Once PHP 7.3 is installed, we need to install the PHP module using the below command.
# apt-get install -y php7.3 libapache2-mod-php7.3 php7.3-curl php7.3-gmp php7.3-mbstring php7.3-phpdbg php7.3-sqlite3 php7.3-zip php7.3-bcmath php7.3-dba php7.3-imap php7.3-pspell php7.3-sybase php7.3-bz2 php7.3-dev php7.3-interbase php7.3-mysql php7.3-readline php7.3-tidy php7.3-cgi php7.3-enchant php7.3-intl php7.3-odbc php7.3-recode php7.3-xml php7.3-cli php7.3-fpm php7.3-json php7.3-opcache php7.3-snmp php7.3-xmlrpc php7.3-common php7.3-gd php7.3-ldap php7.3-pgsql php7.3-soap php7.3-xsl php7.3-mongo

php 7 install

Step #4 – Install and Setup Magento 2.4

  • The next step of the process is to install and setup Magento 2.4.
  • For this, we need to first create a directory and download the Magento 2.4 file using the below two commands:

To create a directory:

Create Directory

To download Magento 2.4 from the official website:

Download Magento 2.4

After the downloading is finished, unzip the zip file in the same folder.

  • Next, we need to give the required permissions using the below commands.
# chmod -R 755 magento2.4

chmod -R 755 magento2.4

# chown -R magento:magento magento2.4

chown -R magento:magento magento2.4

# chmod -R 777 var pub generated app

chmod -R 777 var pub generated app

  • Now, it’s time to begin the Magento installation process via the command line.
# php bin/magento setup:install --base-url=


 --db-host=localhost --db-name=magento --db-user=magento --db-password=magento123 --admin-firstname=test --admin-lastname=test --admin-email=test@

 --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1

Magento 2 Front

Step #5 – Install ElasticSearch on Ubuntu

To install ElasticSearch on Ubuntu, we need to first install Java as it is necessary for the dependencies.

# apt-get update

# apt install openjdk-8-jdk

apk install

# java -version


  • After this, we need to install it from the APT repository as well.
# sudo apt install apt-transport-https

sudo apt installation

  • Now, we will download and install ElasticSearch.

Install elastic search

magento 2.4

# apt-get update

apt get update

# apt-get install elasticsearch

Elastic search apt-get

# systemctl daemon-reload

systemctl daemon-reload

# systemctl enable elasticsearch.service

systemctl enable elasticsearch

# systemctl start elasticsearch.service

systemctl start elasticsearch

# service elasticsearch status

service elasticsearch status

Now, the default ElasticSearch configuration does not allow your system to be accessed by other hosts.

Therefore, you’ll need to allow remote access manually by editing the elasticsearch.yml file using a text editor software.

elasticsearch magento

install magento 2.4 elastic search

# ufw allow 22

ufw allow 22

# ufw enable

ufw enable

# ufw status

ufw status

# curl localhost:9200

curl localhost:9200

Step #6 – ElasticSearch Configuration in Magento

Finally, let’s see how to properly configure ElasticSearch in Magento 2.4.

First of all, login to your admin panel and navigate to Stores > Configuration.

Configure Elastic Search Magento 2.4

After that, select Catalog under the Catalog section from the sidebar.


Next, click on the catalog to expand the section.

Catalog Search

After that, clear the Use System Value checkbox in the search engine field and select the version of ElasticSearch that is installed on your server.

Catalog Search Window

Next, we need to configure the ElasticSearch connection through the following instructions.

Elastic Search Configure


  • Write ElasticSearch Server Hostname.
  • Write ElasticSearch Server Port.
  • Write a prefix in ElasticSearch Index Prefix.
  • Select YES in the Enable ElasticSearch HTTP Auth field.
  • Enter a number of seconds before the system times out in the ElasticSearch Server Timeout field.
  • Click on the Test Configuration button to verify the configuration.

Lastly, click on the Save Config button to finish the process.


And that’s about it!

This is the entire process of Magento 2.4 installation with ElasticSearch.

The process is sure lengthy but it will get the job done if you follow it exactly.

Alternatively, you can also directly incorporate Magento 2 ElasticSearch Extension once your store is live to avoid this hassle.

And if you need our professional assistance with Magento Development Agency, feel free to contact us anytime.