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:
- 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 update2.Install Redis by running the following command:
sudo apt install redis3.Check if Redis is running by running the following command:
sudo systemctl status redisThe 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 tcl2.Download the latest stable Redis source code from the official website using the following command:
wget http://download.redis.io/redis-stable.tar.gz3.Extract the downloaded tarball using the following command:
tar xzf redis-stable.tar.gz4.Navigate into the extracted directory using the following command:
cd redis-stable5.Compile Redis using the following command:
make6.Test the compiled Redis binary using the following command:
make test7.Install Redis using the following command:
sudo make install8.Configure Redis to start automatically on system boot using the following command:
sudo systemctl enable redis9.Check if Redis is running by running the following command:
sudo systemctl status redisThe 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?
Help us improve by giving us your feedback.
Other Common Redis Questions (and Answers)
- How to install Redis on Mac?
- How to check if Redis is running?
- How to restart Redis?
- Does Redis persist data?
- How to stop Redis server?
- How to see Redis version?
- How long does Redis store data?
- How is Redis so fast?
- How to connect to Redis server?
- Is Redis Multithreaded?
- Does Redis Use HTTP?
- Is Redis a Relational Database?
Free System Design on AWS E-Book
Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Switch & save up to 80%
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost