Introducing Dragonfly Cloud! Learn More

Question: How to install Redis on Ubuntu?

Answer

Redis is an in-memory data structure store that is commonly used for caching and real-time data processing. Installing Redis on Ubuntu is a straightforward process, and there are two ways to do it.

Method 1: Installing Redis from the Default Ubuntu Repository

This is the easiest and most convenient way to install Redis on Ubuntu. Here are the steps:

  1. Add the repository to the apt index, update it, and then install
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg 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 sudo apt-get update

2.Install Redis by running the following command:

sudo apt install redis

3.Check if Redis is running by running the following command:

sudo systemctl status redis

The output should indicate that Redis is active and running.

Method 2: Installing Redis from Source

This method involves compiling Redis from source code, which can be more complex than installing it from a package manager but gives you more control over the installation process. Here are the steps:

1.Install the build-essential and tcl packages by running the following command:

sudo apt install build-essential tcl

2.Download the latest stable Redis source code from the official website using the following command:

wget http://download.redis.io/redis-stable.tar.gz

3.Extract the downloaded tarball using the following command:

tar xzf redis-stable.tar.gz

4.Navigate into the extracted directory using the following command:

cd redis-stable

5.Compile Redis using the following command:

make

6.Test the compiled Redis binary using the following command:

make test

7.Install Redis using the following command:

sudo make install

8.Configure Redis to start automatically on system boot using the following command:

sudo systemctl enable redis

9.Check if Redis is running by running the following command:

sudo systemctl status redis

The output should indicate that Redis is active and running.

That's it! You should now have Redis up and running on your Ubuntu machine.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.