In this section, we will cover the steps required to install Redis on different operating systems. By the end of this module, you will have Redis up and running on your machine, ready for you to start exploring its features.
Table of Contents
Installing Redis on Linux
Using Package Manager (Ubuntu/Debian)
-
Update your package list:
sudo apt update
-
Install Redis:
sudo apt install redis-server
-
Start Redis server:
sudo systemctl start redis-server
-
Enable Redis to start on boot:
sudo systemctl enable redis-server
Using Package Manager (CentOS/RHEL)
-
Add the EPEL repository:
sudo yum install epel-release
-
Install Redis:
sudo yum install redis
-
Start Redis server:
sudo systemctl start redis
-
Enable Redis to start on boot:
sudo systemctl enable redis
Building from Source
-
Install build dependencies:
sudo apt update sudo apt install build-essential tcl
-
Download the latest stable version of Redis:
curl -O http://download.redis.io/redis-stable.tar.gz
-
Extract the tarball:
tar xzvf redis-stable.tar.gz
-
Compile Redis:
cd redis-stable make
-
Run the Redis test suite:
make test
-
Install Redis:
sudo make install
Installing Redis on macOS
Using Homebrew
-
Install Homebrew if you haven't already:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install Redis:
brew install redis
-
Start Redis server:
brew services start redis
-
Stop Redis server (if needed):
brew services stop redis
Installing Redis on Windows
Using Redis for Windows
-
Download the latest Redis MSI installer from the Microsoft Open Tech Group's GitHub repository.
-
Run the installer and follow the prompts to complete the installation.
-
Start Redis server:
- Open Command Prompt as Administrator.
- Navigate to the Redis installation directory.
- Run the following command:
redis-server
Verifying the Installation
-
Open a terminal or command prompt.
-
Run the Redis CLI:
redis-cli
-
Ping the Redis server to check if it's running:
127.0.0.1:6379> PING
-
You should receive a response:
PONG
Conclusion
In this section, we covered how to install Redis on various operating systems including Linux, macOS, and Windows. We also verified the installation to ensure that Redis is running correctly. In the next module, we will explore the basic data types in Redis and how to interact with them using the Redis CLI.
Redis Course
Module 1: Introduction to Redis
Module 2: Redis Data Structures
Module 3: Redis Commands and Operations
Module 4: Redis Persistence
Module 5: Redis Security
Module 6: Redis Performance Optimization
Module 7: Redis Clustering and High Availability
Module 8: Redis Modules and Extensions
- Introduction to Redis Modules
- Popular Redis Modules
- Creating Custom Modules
- Using Redis with Other Technologies