75% OFF ALL NEW PLANS TO HELP MORE BUSINESSES MOVE ONLINE

How to install and run Elasticsearch

In this guide, we will install and run Elasticsearch. Due to the specifics of Elasticsearch, we will actually need to create two WebApps to complete our setup. To install and run Elasticsearch as a WebApp, please follow these steps.

Create the necessary directories and files

1. Create a subdomain.

You need to create a subdomain for your Elasticsearch WebApp through the Subdomains section of the Control Panel. In this guide, we will call the subdomain elastic-sub.

2. Create the necessary directories.

Create a directory for the Elasticsearch installation in the /private directory on your account. In this guide, we will call the directory elasticsearch_dir. You can easily create directories through the File Manager in the Control Panel of your account.

Create a directory for the Portholder WebApp in the /private directory on your account. In this guide, we will call the directory portholder_dir.

3. Create the WebApps.

Create a WebApp for Elasticsearch through the WebApps section of the Control Panel. Remember the port number assigned to the WebApp. Use the following settings:

Create another WebApp. This app will be used to reserve another port for Elasticsearch. We will call this WebApp Portholder. Remember the port assigned to the Portholder WebApp. We are going to use this port in the Elasticsearch configuration. Since we are not going to activate this WebApp, you can use any settings you wish, as long as there are no conflicts with existing WebApps. In this guide, we are using the the following settings:

Install and configure Elasticsearch

4. Download and extract the Elasticsearch installation package.

Log in to your account over SSH. Logging in over SSH is covered in the SSH section in our documentation. Then, navigate to the directory that you created for your Elasticsearch installation. You can do this by running the following command (make sure you replace the path in the command with the actual path to the directory you created for Elasticsearch):

cd ~/private/elasticsearch_dir

Use wget to download the latest Elasticsearch LINUX X86_64 package directly to your elasticsearch_dir. You can get the URL to the latest Elasticsearch package at the official Elasticsearch website. If you need to enable wget, you can do it through the SSH Access section of your account's Control Panel.

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.2-linux-x86_64.tar.gz

Use tar to extract the archive:

tar -xzf elasticsearch-7.9.2-linux-x86_64.tar.gz

5. Configure Elasticsearch.

Create a start.sh file in your elasticsearch_dir directory with the following content:

#!/bin/bash
cd /home/username/private/elasticsearch_dir/elasticsearch-7.9.2/
export ES_JAVA_OPTS="-Xms128m -Xmx128m"
exec ./bin/elasticsearch

Make sure you replace the path in the command with the actual path to the directory you created for Elasticsearch and the version number with the version corresponding to the package you downloaded. You need to replace username with the actual username of your account's Control Panel. You can easily create and edit files through the File Manager in the Control Panel of your account.

Edit the following configuration file in the directory where Elasticsearch is extracted:

/home/username/private/elasticsearch_dir/elasticsearch-7.9.2/config/elasticsearch.yml

There, you need to remove the # symbol in front of the http.port setting, and replace the port number with the port assigned to the Elasticsearch WebApp you created at step 3. You also need to insert a new line for the transport.port setting. Since this setting requires a range, you will need to set the port assigned to the Portholder WebApp you created at step 3 as the beginning and the end of the range:

http.port: XXXX #Elasticsearch WebApp port
transport.port: YYYYY-YYYYY #Portholder WebApp port

Go back to the WebApps section of the Control Panel. There click on the edit button next to the Elasticsearch WebApp, and set the Elasticsearch WebApp start command to the following:

sh /home/username/private/elasticsearch_dir/start.sh

Make sure you replace the path in the command with the actual path to the start.sh file you created.

That's it!

Once you start your WebApp, Elasticsearch should be running on the specified port.