By default, ElasticSearch 7 is needed for Magento 2.4. So we should install ElasticSearch 7 before we install Magento 2.4.
First Step, Check JDK is install or not, if not, install Install the JDK on CentOS.
We cannot install ElasticSearch 7 directly, we should check JDK on CentOS in installed or not, I run CentoOS 8, run:
$ java -version
If JDK is not installed, we should install it, by running the command:
yum -y install java-1.8.0-openjdk
Be sure to install the JDK and not the JRE.
Now we run java -version again, we should get:
openjdk version “1.8.0_272”
OpenJDK Runtime Environment (build 1.8.0_272-b10)
OpenJDK 64-Bit Server VM (build 25.272-b10, mixed mode)
Second Step, Install Elasticsearch with RPM.
Download and install the RPM manually.
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-7.10.1-x86_64.rpm.sha512
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-x86_64.rpm wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-x86_64.rpm.sha512 shasum -a 512 -c elasticsearch-7.12.1-x86_64.rpm.sha512 sudo rpm --install elasticsearch-7.12.1-x86_64.rpm
shasum command not found centos 7
yum install -y perl-Digest-SHA
sudo rpm --install elasticsearch-7.12.1-x86_64.rpm
Compares the SHA of the downloaded RPM and the published checksum, which should output elasticsearch-{version}-x86_64.rpm: OK.
sudo rpm –install elasticsearch-7.10.1-x86_64.rpm
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
Enable ElasticSearch service by simply running:
sudo systemctl enable elasticsearch.service
More: elastic.co/guide/en/elasticsearch/reference/current/rpm.html
Verify it’s running:
<!– wp:code –>
<pre class=”wp-block-code”><code>curl -X GET “localhost:9200/?pretty”</code></pre>
<!– /wp:code –>
Should yield:
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1601396097 16:14:57 elasticsearch yellow 1 1 3 3 0 0 3 0 – 50.0%
If displays:
curl: (7) Failed to connect to localhost port 9200
cd /etc/elasticsearch/
vi elasticsearch.yml
modifiy #network.host 192.169.0.1
to:
network.host 0.0.0.0
save and exit.
Configure Elasticsearch within Magento
To configure Magento to use Elasticsearch:
Log in to the Magento Admin as an administrator.
Click Stores > Settings > Configuration > Catalog > Catalog > Catalog Search.
From the Search Engine list, select your Elasticsearch version.
Now, reindex everything:
bin/magento indexer:reindex
Tips
If you want to reset ElasticSearch indexes, here’s a handy command:
curl -X DELETE ‘http://localhost:9200/_all’
————————————————–
Third, Install Magento 2.4
Upload all files to web hosting.
PHP bin/magento setup:install –base-url=http://127.0.0.1/magento2/ \
–db-host=localhost –db-name=magento –db-user=magento –db-password=magento \
–admin-firstname=Magento –admin-lastname=User –admin-email=user@example.com \
–admin-user=admin –admin-password=admin123 –language=en_US \
–currency=USD –timezone=America/Chicago –use-rewrites=1 \
–search-engine=elasticsearch7 –elasticsearch-host=es-host.example.com \
–elasticsearch-port=9200
Elasticsearch 7 is installed on es-host.example.com and connects on port 9200, Elasticsearch 7 is installed at your localhost, then use:
Elasticsearch 7 is installed on es-host.example.com and connects on port 9200
PHP bin/magento setup:install –base-url=http://127.0.0.1/magento2/ \
–db-host=localhost –db-name=cheapglasses –db-user=discountglasses –db-password=’YourPassWordHere’ \
–admin-firstname=sunglasses –admin-lastname=safetyglasses –admin-email=user@example.com \
–admin-user=admineye –admin-password=admineyewear –language=en_US \
–currency=USD –timezone=America/Chicago –use-rewrites=1 \
–search-engine=elasticsearch7 –elasticsearch-host=localhost \
–elasticsearch-port=9200
Forth Step, 2.4 Fresh Install Admin Account with Two Factor Authentication – first time login, if we do not like to use Two Factor Authentication for the first time login, just run the command:
bin/magento module:disable Magento_TwoFactorAuth
Fifth, sometimes we may meet the following error message when we visit or login the new shop:
An error has happened during application run. See exception log for details.
Just run:
chmod -R 0777 var/ pub/ generated/
=====================================
Install OpenJDK 11
Open a terminal window and enter the following:
sudo yum install java-11-openjdk-devel
Confirm any prompts, allow the process to finish, and verify the installation with:
java -version