Redis on Ubuntu 22.04: Installation & Security

 

Redis can significantly improve the performance of your system. We will show you how to configure and back up the powerful in-memory database efficiently and securely on Ubuntu 22.04.

REmote DIctionary Server is a powerful in-memory database storage that is often used for caching and messaging purposes. In this blog post, we explain how to install and configure the software on an Ubuntu 22.04 system to ensure secure and efficient performance.

Step 1: Install Redis

First you need to install the software on your Ubuntu 22.04 system. To do this, open a terminal and execute the following commands:

sudo apt update
sudo apt install redis-server

Step 2: Configure Redis

After installation, you must edit the configuration file to ensure optimum performance and security. Open the file /etc/redis/redis.conf with a text editor of your choice:

sudo nano /etc/redis/redis.conf

You should make the following changes in the configuration file:

  • Supervised Directive: Change supervised no to supervised systemd. This allows Redis to run under the control of systemd.
  • Bind Directive: Change bind 127.0.0.1 ::1 to bind 127.0.0.1, to restrict Redis to localhost and prevent external access.

Save the file and exit the editor.

Step 3: Restart Redis

After you have changed the configuration, restart the software to apply the changes:

sudo systemctl restart redis.service

Step 4: Secure Redis

 

Take the following steps to protect your server from unauthorized access:

  • Password protection: Add a requirepass directive to the configuration file and set a strong password.
  • Firewall settings: Make sure that your server is not publicly accessible. Use firewall rules to restrict access.

Step 5: Check installation

Use the following client to check whether the in-memory database storage is working properly:

redis-cli

After entering the password (if set), you should be able to execute commands and interact with your instance.

Conclusion

Installing and securing Redis on Ubuntu 22.04 is a straightforward process that can significantly improve the performance of your system. By following these steps, you will ensure that your Redis server runs securely and efficiently.