• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install and Configure Redis on Ubuntu 20.04

Written by Admin, Updated On May 18, 2020
redis, ubuntu
How to Install and Configure Redis on Ubuntu 20.04

Redis is an in-memory key-value store and used as a database server, cache, and message broker. Redis supports wide languages with flexibility and high performance. This tutorial will demonstrates how to install and configure Redis on Ubuntu 20.04 system.

Prerequisites#

  • Make sure you logged in as root or non-root user account with sudo privileges.
  • IPv6 should be enabled on your server otherwise Redis service will fail to start.

Install Redis on Ubuntu#

At first, to get the latest version of Redis, we will update apt package cache:

sudo apt update && sudo apt upgrade
sudo apt install redis-server

This will install Redis and its dependencies. On the completion of installation, Redis service will be start automatically. You can verify it by typing:

sudo systemctl status redis-server

It should show below output:

● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-05-15 18:20:12 PDT; 37s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 2205 (redis-server)
Tasks: 4 (limit: 2349)
Memory: 6.9M
CGroup: /system.slice/redis-server.service
└─2205 /usr/bin/redis-server 127.0.0.1:6379

That’s it! Redis is ready to use on your Ubuntu server.

Configure Redis#

By default, Redis is configured to listen on localhost only. You can connect to the Redis server only from the same machine where its service is running.

If you want to configure Redis to accept remote connections, open the Redis configuration file with your text editor using below command:

sudo nano /etc/redis/redis.conf

Now comment the line bind 127.0.0.1 ::1 by adding # at the beginning of line.

Save the file and close.

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.0.0.1 ::1

You should restart the Redis service for changes to take effect:

sudo systemctl restart redis-server

Run the below command to verify:

ss -an | grep 6379

It should show as below output:

tcp  LISTEN  0  128  0.0.0.0:6379  0.0.0.0:*                     
tcp  LISTEN  0  128  [::]:6379     [::]:* 

If your are using firewall, you’ll also need to add a firewall rule to enable traffic from your remote machines on TCP port 6379. If you are using UFW, run below command:

sudo ufw allow proto tcp from 192.168.0.0/16 to any port 6379

Ensure that your firewall is configured to accept connections only from trusted IP ranges.

Now to test that Redis is functioning correctly, connect to the server using redis-cli utility by pinging the Redis server from your remote machine:

redis-cli -h <REDIS_IP_ADDRESS> ping

You should see exact below output:

PONG

You can exit the redis-cli shell by typing:

exit

Conclusion#

You have successfully learned how to install Redis on Ubuntu 20.04 server. To find more information about how to manage your Redis installation, visit the Redis documentation page.

If you have any queries please don’t forget to comment out.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article Cut Command in Linux
Next Article   How to Add Apt Repository In Ubuntu / Debian

Related Posts

  • How to Install and Use PHP Composer on Ubuntu 22.04

    How to Install Composer on Ubuntu 22.04

    January 31, 2023
  • How to Install Nginx on Ubuntu 22.04

    How to Install Nginx on Ubuntu 22.04

    January 28, 2023
  • How to Install Puppet Agent on Ubuntu 22.04

    How to Install Puppet Agent on Ubuntu 22.04

    January 22, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Python 3.11 on Debian 11
    How to Install Python on Debian 11 January 25, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook