# How To Install Redis on Ubuntu 22.04

## Redis:&#x20;

Redis (**RE**mote **DI**ctionary **S**erver) is an open source, in-memory, NoSQL key/value store that is used primarily as an application cache or quick-response database.

Getting started with Redis

**1. System Update**

```
sudo apt update
sudo apt upgrade -y
```

***

**2. Add Redis Official APT Repository**

Install required packages:

```
sudo apt-get install lsb-release curl gpg -y
```

Import Redis GPG key:

```
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
```

Set correct permissions:

```
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
```

Add Redis repository to APT sources:

```
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
```

Update APT cache:

```
sudo apt-get update
```

***

**2. Add Redis Official APT Repository**

```
sudo apt-get install redis -y
```

***

**4. Enable Redis Service**

```
sudo systemctl enable redis-server
sudo systemctl start redis-server
sudo systemctl status redis-server
```

***

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FTPCzQswcACS8pGqvIb9Q%2Fimage.png?alt=media&#x26;token=ac80e0bf-d3d4-4a45-8dce-400f6e6dcdb6" alt=""><figcaption></figcaption></figure>

**5. Test Redis Service**

```
redis-cli
ping
```

**Expected output:**

```
PONG
```

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FHloExJfKKVzAuk0d7iny%2Fimage.png?alt=media&#x26;token=232787d3-df42-4cf8-882d-d5f3d44a41ff" alt=""><figcaption></figcaption></figure>

Exit:

```
exit
```

***

**6. Configure Redis for systemd & Security**

Open configuration file:

```
sudo nano /etc/redis/redis.conf
```

**6.1 Enable systemd supervision**

Search or manually add:

```
supervised systemd
```

**6.1 Enable systemd supervision**

Find:

```
# requirepass foobared
```

Uncomment and modify:

```
requirepass <YourStrongPassword>  #set your db password
```

**6.3 (Optional) Enable Remote Access**

Only if required for external applications:

```
bind 0.0.0.0
```

Save and exit (`CTRL+O`, Enter, `CTRL+X`)

Restart Redis:

```
sudo systemctl restart redis-server
```

***

**6.3 (Optional) Enable Remote Access**

```
redis-cli
AUTH <YourStrongPassword>
ping
```

Output:

```
PONG
```
