What is Redis?
Redis is an in-memory data store that uses a key/value model. It can be used as a database but is usually used for cache.
We can install Redis from the official Debian repositories, for this we will first update the repository and then install the Redis server:
sudo apt update sudo apt install redis-server
To verify that Redis is running on the system we can use the following command
sudo systemctl status redis-server
Set up Redis
To configure Redis we need to modify its configuration file called “redis.conf” located in the “/etc/redis” directory. On
a remote server we can modify this file via SFTP, or from the terminal using the following command:
sudo nano /etc/redis/redis.conf
Once we have the settings that we want we should exit the editor using CTRL + X, then it will ask us that if we want to save the file and give the Y followed by the Enter.The c
hanges will not take effect until we restart the server, for this we use the following command in the terminal
sudo systemctl restart redis.service
By default Redis does not allow remote connections because its default settings are listened to under IP address 127.0.0.1We ca
n change this by commenting to the following line in the settings:
bind 127.0.0.1 ::1
We’ll add a s to the beginning, so it would look like this:
# bind 127.0.0.1 ::1
Set password for Redis
If we want to improve security or if we open the Redis server to be accessed outside our local network then it is essential to place an access password. F
or this we will go to the Redis settings and place a password on the line that says “requirepass”. This may be commented out, but simply remove the at the beginning if you’ve had one.
In this case we will place it so that the access password is “mysupersecretpassword50391”.
In this post we saw how to install and configure Redis, which is a quite powerful tool to store temporary data which are needed with a high read and write speed (such as Cache, for example)We mostly
learned to configure since it can give, for different circumstances, that the default configuration would not suit us.