# How to install Redis on Ubuntu

Looking to speed up your applications? Redis is a powerful in-memory data store used for caching, sessions, queues, and real-time features. In this guide, we’ll install and configure Redis step by step.

***

### What Redis Is Used For

* Cache database queries (faster websites)
* Store user sessions
* Build real-time features (chat, notifications)
* Handle background jobs (queues)
* Temporary storage (carts, game states)

***

### Requirements

* Linux VPS (Ubuntu 20.04+ recommended)
* SSH access with sudo privileges
* \~10 minutes

***

### Step 1: Update Your System

```bash
sudo apt update
```

(Optional)

```bash
sudo apt upgrade -y
```

***

### Step 2: Install Redis

#### Ubuntu / Debian

```bash
sudo apt install redis-server -y
```

#### CentOS / RHEL 8+

```bash
sudo dnf install redis -y
```

#### CentOS / RHEL 7

```bash
sudo yum install epel-release -y
sudo yum install redis -y
```

***

### Step 3: Start and Enable Redis

```bash
sudo systemctl start redis
sudo systemctl enable redis
sudo systemctl status redis
```

***

### Step 4: Test Redis

```bash
redis-cli
ping
```

Expected output:

```
PONG
```

***

### Step 5: Secure and Configure Redis

```bash
sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.backup
sudo nano /etc/redis/redis.conf
```

Recommended changes:

```
bind 127.0.0.1 ::1
requirepass YourStrongPassword123!
maxmemory 256mb
maxmemory-policy allkeys-lru
```

***

### Step 6: Restart Redis

```bash
sudo systemctl restart redis
```

***

### Done 🎉

Redis is now ready to use.
