Redis is an in-memory key-value store known for its flexibility, performance, and wide language support. This tutorial demonstrates how to install, configure, and secure Redis on an Ubuntu 22.04 server using EcoStack Cloud.
redisubuntudatabase
Medium
VPS
2
vCPU
8 GB
Memory
80 GB
NVMe Disk
4096 GB
Traffic
20.90€
/month
* Up to 4 vCPU, 24GB RAM, 240GB NVMe Disk Space and 1Gbit/s Network Speed
## Prerequisites
To complete this guide, you will need access to an Ubuntu 22.04 server from EcoStack Cloud that has a non-root user with sudo privileges and a firewall configured with `ufw`. You can set this up by following our Initial Server Setup guide for Ubuntu 22.04.
## Installing and Configuring Redis
We’ll use the APT package manager to install Redis from the official Ubuntu repositories. As of this writing, the version available in the default repositories is 6.0.16.
Begin by updating your local apt package cache:
```sh
sudo apt update
```
Then install Redis by typing:
```sh
sudo apt install redis-server
```
This will download and install Redis and its dependencies. Following this, there is one important configuration change to make in the Redis configuration file, which was generated automatically during the installation.
Open this file with your preferred text editor:
```sh
sudo nano /etc/redis/redis.conf
```
Inside the file, find the `supervised` directive. This directive allows you to declare an init system to manage Redis as a service, providing you with more control over its operation. The `supervised` directive is set to `no` by default. Since you are running Ubuntu, which uses the systemd init system, change this to `systemd`:
```plaintext
/etc/redis/redis.conf
. . .
# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
# supervised auto - detect upstart or systemd method based on
# UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
# They do not enable continuous liveness pings back to your supervisor.
supervised systemd
. . .
```
That’s the only change you need to make to the Redis configuration file at this point, so save and close it when you are finished. If you used `nano` to edit the file, do so by pressing `CTRL + X`, `Y`, then `ENTER`.
Then, restart the Redis service to reflect the changes you made to the configuration file:
```sh
sudo systemctl restart redis.service
```
With that, you’ve installed and configured Redis and it’s running on your machine. Before you begin using it, though, it’s prudent to first check whether Redis is functioning correctly.
---