Database
NoSQL
Redis
Installation & Setup

Installation & Setup

Redis can be installed on various platforms. For development and production, using Docker or specialized package managers is recommended.

1. Installation

On macOS (Homebrew)

brew install redis

On Linux (Ubuntu/Debian)

sudo apt update
sudo apt install redis-server

Using Docker (Recommended)

docker run --name my-redis -p 6379:6379 -d redis

2. Starting the Redis Server

If installed via package manager:

# Start the server
redis-server
 
# Check status (Linux)
sudo systemctl status redis

3. Using the Redis CLI

The redis-cli is the built-in tool for interacting with the server.

redis-cli
 
# Test connection
127.0.0.1:6379> ping
PONG

4. Configuration Basics

The configuration file is typically located at:

  • macOS: /usr/local/etc/redis.conf
  • Linux: /etc/redis/redis.conf

Important Parameters:

  • bind 127.0.0.1: Restrict access to local host (Security).
  • port 6379: Default port.
  • requirepass yourpassword: Set a password for access.
  • maxmemory 2gb: Limit memory usage.
  • maxmemory-policy allkeys-lru: Define what happens when memory is full.

[!IMPORTANT] In production, always change the default port and set a strong password (requirepass). Never expose Redis directly to the public internet without a firewall.