## What is Elasticsearch?

![Elasticsearch logo](/api/help/media/d5101738-1a79-4416-9bd1-4c58cb64036e)

**Elasticsearch** is a search engine known for its high performance. It integrates with many environments and is especially popular on websites, for example online stores built with PrestaShop or Magento.

It installs at the operating-system level, depends on Java and requires execution permissions on the `/tmp` directory. This makes a secure integration in a shared hosting environment very complex.

Bottom line: Elasticsearch needs a [VPS server](https://ginernet.com/es/vps/). But do not worry - it is very easy to install and **costs less than €10/month**. Also, you do **not** need to move your website: an additional VPS running the search engine is enough.

## Installing Elasticsearch on a Debian VPS

:::info
Your VPS needs **at least 2 GB of RAM**. You will need more resources depending on how much data you index and the search workload it has to process.
:::

Once you have your VPS, install it with **Debian** (the default operating system). You will receive an e-mail with the connection details: the VPS's dedicated IP and the root password.

Connect to your server over SSH and run the following commands:

```bash
apt update; apt dist-upgrade -y; apt install gnupg curl nano wget sudo apt-transport-https -y;
```

```bash
timedatectl set-timezone Europe/Madrid
```

```bash
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -; apt update;
```

To install **Elasticsearch v7**, run:

```bash
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-7.x.list; apt install elasticsearch -y;
```

To install **Elasticsearch v8** instead, run:

```bash
echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-8.x.list; apt install elasticsearch -y;
```

Then edit the `/etc/elasticsearch/elasticsearch.yml` file and set the `xpack.security.enabled` variable to `false`:

```bash
nano /etc/elasticsearch/elasticsearch.yml
```

```yaml
xpack.security.enabled: false
```

Finally, start the service and enable it so it starts automatically when the VPS reboots:

```bash
systemctl restart elasticsearch
systemctl enable elasticsearch
```

Check that the service is up:

```bash
systemctl status elasticsearch
```

And that it responds to requests:

```bash
curl -X GET localhost:9200
```

Done - Elasticsearch is installed!

## Securing the Elasticsearch server

To prevent anyone from connecting to your Elasticsearch, protect it with firewall rules. Install UFW and set the default policy:

```bash
apt install ufw -y
ufw default deny incoming
ufw default allow outgoing
ufw allow 22
ufw allow 80
ufw allow 443
ufw enable
```

Allow connections to port 9200 **only** from your hosting's IP (replace `x.x.x.x` with the IP of the hosting where your website lives):

```bash
ufw allow from x.x.x.x to any port 9200
```

Enable the firewall and review the rules:

```bash
ufw enable
ufw status numbered
```

:::tip
Any questions? [Contact our technical support](https://ginernet.com/es/contacto/) - we will be happy to help.
:::