Magento 2.4 has significantly changed its installation process, no longer supporting the web install wizard. This shift requires users to rely on command line interfaces for installation, a challenge particularly for those unaccustomed to such environments.

Attention to deploying Magento 2.4 with Elasticsearch on a live server, specifically on Ubuntu OS (versions 16.04 or 23.10).

Before diving into the installation process, it’s important to address Elasticsearch, a term familiar to many but perhaps new to some. Fear not if you’re among the latter group; our guide is designed to demystify Elasticsearch. We’ll explore its origins, applications, advantages, and more, offering a comprehensive understanding crucial for those delving into the deeper aspects of Magento 2.4 with Elasticsearch. This foundational knowledge is key to successfully installing and efficiently using these powerful tools.

Release of Magento 2.4 – Key Highlights & Emergence of Elasticsearch

Magento 2.4 has been released to enhance security, for better security payment gateways, performance, inventory or stock management, and for resolving existing issues. The highlights of Magento 2.4:

  • Security Patches
  • Platform Upgrades
  • Infrastructure Improvements
  • Performance Improvements
  • Purchase Approval Workflows
  • Seller-assisted shopping
  • In-Store Pickup
  • New Media Gallery
  • PWA Improvements

Well, we will now know how Elasticsearch came into existence. In Magento 2.4, the platform upgrades will enhance the performance of the Magento store and its security. It will be supported by PHP 7.4. Moreover, there is also support for PHPUnit 9.x, Elasticsearch 7.6.x support, and MySQL 8.0 support. The MySQL catalog search engine has been removed and replaced by Elasticsearch’s default search engine. For more, visit here- Magento Open Source 2.4 Release Notes

Earlier Options for Deploying Elasticsearch

Before the release of Magento 2.4, and now as well, Elasticsearch is deployed as a managed, hosted service all through Elasticsearch Service. Moreover, it is permitted to download and install on our hardware or in the cloud. The one who needs to provision, handle, and monitor his deployments from a single code but chooses not to use a public cloud platform, Elastic provides Elastic Cloud Enterprise and Private subscription tier.

What Is Elasticsearch?

A RESTful, distributed search and analytics engine, Elasticsearch can locate an expanding number of use cases. Being the heart of the Elastic Stack, Elasticsearch stores your data centrally for rapid search, powerful analytics, and fine-tuned relevancy that scales easily. Simply put, Elasticsearch aids in storing and mapping all documents effectively to optimize the search and retrieval function.

A powerful, open-source analytic and search engine, Elasticsearch uses Apache Lucene. Apart from handling many use cases, it supports various tenancies and a full-text search on the HTTP web interface.

Benefits of Elasticsearch

  • Real-Time Search: Elasticsearch, based on Lucene, excels in full-text search with near real-time capabilities, ideal for time-sensitive tasks like infrastructure monitoring and security analytics.
  • Distributed Architecture: It distributes documents across shards, allowing redundancy and reliability, and scales across hundreds to thousands of servers to manage petabytes of data.
  • Feature-Rich: Beyond speed and scalability, Elasticsearch offers advanced features for efficient data storage and searching, such as data rollups and index lifecycle management.
  • Elastic Stack Integration: Enhances data processing, ingestion, reporting, and visualization with tools like Logstash and Beats for data processing and Kibana for real-time visualization and easy access to application performance, infrastructure metrics, and logs.

Why Use Elasticsearch In Magento 2?

In the world of eCommerce, especially for sites built on Magento 2, search functionality stands as a cornerstone feature. A robust search tool, like Elasticsearch, significantly enhances the shopping experience. It enables customers to locate their desired products effortlessly, potentially boosting sales and improving overall customer satisfaction.

Conversely, a subpar search tool can hinder product discovery, increasing bounce rates and lost sales opportunities. This underscores the criticality of incorporating advanced search capabilities in Magento 2 stores. Implementing Elasticsearch is an exemplary strategy to achieve this.

However, it’s important to note that Elasticsearch integration is native only to Magento Commerce Edition and Magento Open Source 2.3.0. Installing a compatible module is essential for those utilizing Magento Open Source 2.2.x to leverage Elasticsearch’s powerful features. Various Magento 2 Elasticsearch modules are available, catering to diverse needs with free and paid options.

Also Read: How to Hire A Magento 2 Developer – Complete Guide

Uses of Elasticsearch

The scalability and speed of Elasticsearch and its caliber to index various types of content states that it can be employed for several use cases:

  • Website search
  • Application search
  • Enterprise search
  • Infrastructure metrics & container monitoring
  • Logging & log analytics
  • Application performance monitoring
  • Security analytics
  • Geospatial data analysis & visualization
  • Business Analytics

Now, we will move on to the process of Magento 2.4 Installation with Elasticsearch. Let’s get started.

Checking System Requirements Before Installing Magento 2.4

Before installing Magento 2.4, it’s crucial to ensure your server or VPS aligns with Magento 2’s system requirements. Here are the server specifications I suggest:

  • A minimum of 2GB RAM is required. However, 4GB RAM is recommended for enhanced performance, particularly when using Elasticsearch.
  • For CPU, a 3-core processor should suffice for small to medium-sized businesses. To estimate the required number of cores, you can use the following formula: Number of cores = ([Number of Expected Requests] / 2) + [Number of Expected Cron Processes].

Install Apache2 on Ubuntu

First, we need to install a lamp setup via the command line. I have using apache2 for a webserver.

Apache HTTP webserver provides many powerful features, including dynamically loadable modules, robust media support, and extensive integration with other popular software.

Step 1 – Install Apache2

# apt-get update
1 apt-get update
# apt-get install -y apache2
2 apt-get install -y apache2

Step 2 – Firewall Allow

# ufw app list
3 ufw app list
# ufw allow 'Apache'
4 ufw allow apache
# ufw status

5 ufw status
When firewall status inactive then we need to enable it.

# ufw enable
6 ufw enable
# ufw status
7 ufw status

Step 3 – Check Web Server

# service apache2 status

8 service apache2 status
Go to Browser and browse with private ip. You should see the default Ubuntu 18.04 Apache web page:9 the default Ubuntu 18.04 Apache web page

Install MySQL on Ubuntu

An open-source database management system, MySQL is commonly installed like a part of the famous LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It employs a relational database along with SQL (Structured Query Language) to handle its data.

Step 1 – Install MySQL

# apt-get update
10 apt-get update
# apt-get install mysql-server
apt-get install mysql-server

Step 2 – Configuring MySQL

11 Configuring MySQL
Enter a three level of password validation and also given a root password:12 three level of password validation

# mysql
13 mysql

Step 3 – Create a MySQL User

Creating a new user and give it a strong password.

mysql> CREATE USER 'magento'@'localhost' IDENTIFIED BY 'magento123';

14 CREATE USER magento localhost
you could grant the user privileges to all tables within the database, as well as the power to add, change, and remove user privileges, with this command.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'magento'@'localhost' WITH GRANT OPTION;
15 magento localhost
mysql> FLUSH PRIVILEGES;
16 mysql FLUSH PRIVILEGES
mysql> exit;

Step 4 – Testing MySQL

# systemctl status mysql
17 systemctl status mysql

Install PHP7.3 on Ubuntu

Step 1 – Install PHP

# apt-get install software-properties-common
18 apt-get install software-properties-common
# add-apt-repository ppa:ondrej/php
19 add-apt-repository ppa ondrej
# apt-get update
20 apt-get update
# apt-get install -y php7.3
21 apt-get install -y php7.3
# php -v
22 # php -v

Step 2 – Installing PHP module

# 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
23 Installing PHP module

Install & Setup Magento 2.4

Step 1 – Create a Directory and Download the Magento2.4 File

Create a directory
24 Create a directory
Download Magento-CE-2.4.0 on official website.
25 Download Magento-CE-2.4.0
After downloading unzip zip file in this folder.

Step 2 – Given Permission

# chmod -R 755 magento2.4
26 chmod -R 755 magento2.4
# chown -R magento:magento magento2.4
27 chown R magento magento magento2.4
# chmod -R 777 var pub generated app
28 chmod -R 777 var pub generated app

Step 3 – Magento Installation

Magento2.4 installation via command line. So we have to create a database and MySQL user already, then run the command below:

# php bin/magento setup:install --base-url=http://http://172.16.16.118/magento2.4/ --db-host=localhost --db-name=magento --db-user=magento --db-password=magento123 --admin-firstname=test --admin-lastname=test [email protected] --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
29 Magento2.4 installation

Install Elasticsearch on Ubuntu

Step 1 – Install Java (It’s necessary for dependencies)

# apt-get update
30 apt-get update
# apt install openjdk-8-jdk
31 apt install openjdk-8-jdk
# java -version
32 java -version

Step 2 – Installing from the APT repository

# sudo apt install apt-transport-https
33 sudo apt install apt-transport-https

Step 3 – Install and Download Elasticsearch

wget
34 Install and Download Elasticsearch
echodeb
35 echo deb

Step 4 – Install Elasticsearch

# apt-get update
36 apt-get update
# apt-get install elasticsearch
37 apt-get install elasticsearch

Step 5 – Start Elasticsearch Service

# systemctl daemon-reload
38 systemctl daemon-reload
# systemctl enable elasticsearch.service
39 systemctl enable elasticsearch.service
# systemctl start elasticsearch.service
40 systemctl start elasticsearch.service
# service elasticsearch status
41 service elasticsearch status

Step 6 – Configure Elasticsearch

The default configuration doesn’t permit your machine to be accessed by other hosts. To allow remote access, use a text editor you want and open the elasticsearch.yml file
Vim
42 Configure Elasticsearch

43 default configuration

Step 7 – ufw to Secure Elasticsearch

# ufw allow 22
44 ufw allow 22
# ufw enable
45 ufw enable
# ufw status
46 ufw status

Step 8 – Test Elasticsearch

# curl localhost:9200
47 Test Elasticsearch

Elasticsearch Configuration in Magento

Step 1 – Configure Search Options

1. From the Admin sidebar, select Stores. Then under Settings, select Configuration.
48 Configure Search Options
2. In the panel on the left of the screen, under CATALOG, select Catalog.
49 CATALOG, select Catalog.
3. Click to Catalog Search to expand this section.
50 Catalog Search
4. In the Search Engine field, clear the Use system value checkbox and select the version of Elasticsearch that is installed on your server.51 Search Engine

Step 2: Configure the Elasticsearch Connection

52 Configure the Elasticsearch Connection
  • 1. Enter the Elasticsearch Server Hostname. The default is localhost
  • 2. Enter the Elasticsearch Server Port.
  • 3. Enter a prefix in the Elasticsearch Index Prefix field to determine the Elasticsearch index. For instance: Magento2.
  • 4. In the Enable Elasticsearch HTTP Auth field, select Yes option to use HTTP authentication to suggest a username and password access Elasticsearch Server.
53 Enable Search Suggestions
  • 5. Enter the number of seconds before the system times out to the Elasticsearch Server Timeout field. The default number is 15.
  • 6. To verify the configuration, click to the Test Connection button.

Step 3: Configure Suggestions and Recommendations

1. In the Enable Search Suggestions field, choose the Yes option. Then, take the following actions:

  • Fill the Search Suggestions Count field with the number of search suggestions to offer.
  • In the Show Results for Each Suggestion field, select Yes option to display the number of results found for each suggestion.

2. In Enable Search Recommendations field, select Yes option to offer recommendations.

  • Fill the Search Recommendation Count field with the number of recommendations to offer.
  • In the Show Results Count for Each Recommendation field, select Yes to display the number of results found for each recommendation.

3. When you finish your configuration, click the Save Config button.

Conclusion

Installing Magento 2.4 on Ubuntu with Elasticsearch, we’ve explored the significant benefits for e-commerce platforms. This combination offers an efficient, scalable, and user-friendly shopping experience, enhanced by Adobe Commerce’s robust features and Magento’s new identity.

As a leading Magento development company, we’re not just implementers but innovators in e-commerce technology. Our exceptional Magento developers deliver bespoke solutions uniquely tailored for your business. With Magento as part of Adobe Commerce, we leverage advanced features to maximize your online store’s potential.

Ready to revolutionize your e-commerce with Magento 2.4? Contact us! We’re dedicated to a smooth transition to Magento 2.4, ensuring impactful results under Adobe’s innovative umbrella.

Avatar photo
Author

CTO at Emizentech and a member of the Forbes technology council, Amit Samsukha, is acknowledged by the Indian tech world as an innovator and community builder. He has a well-established vocation with 12+ years of progressive experience in the technology industry. He directs all product initiatives, worldwide sales and marketing, and business enablement. He has spearheaded the journey in the e-commerce landscape for various businesses in India and the U.S.

whatsapp