Install and configure Redis on Linux Ubuntu from terminal in few simple steps, implementing security with a trusted password

What is Redis

Redis is a memory store, based on the key-value principle, known for its performance and flexibility. Redis is basically a powerful and effective software for creating very fast and high-performance data structures.

The most interesting and widely used tool is the Redis Cache as it can improve the performance of websites by storing frequently used data in memory so that it is quickly available when required.

WARNING. The steps below should be performed by experienced people as they are potentially dangerous and could damage the server. If you do not know what you are doing you can request a free quote.

Install Redis on Linux Ubuntu

To install Redis on Ubuntu, log in ssh to the terminal and proceed with the following steps:

sudo apt update
sudo apt install redis-server

Configuring Redis on Ubuntu Linux

To configure Redis on Ubuntu, edit the Redis configuration file:

sudo nano /etc/redis/redis.conf

Ensure thatRedis execution occurs in localhost by checking that the following instruction exists and is uncommented

bind ::1

if the line was commented out, delete the “#”, save the file, and restart Redis services

sudo systemctl restart redis

To verify that Redis is actually acting in localhost, install the netstat command

sudo apt install net-tools

and check what address Redis is acting on

sudo netstat -lnp | grep redis

you should have an output like the following

tcp        0      0*               LISTEN      14222/redis-server  
tcp6       0      0 ::1:6379                :::*                    LISTEN      14222/redis-server

Where the string means:

  1. redis is acting on thelocal address
  2. redis is acting on port 6379

Protect Redis on Linux Ubuntu

Another very important thing to do is to protect Redis with a password to prevent dangerous external access. Edit the configuration file again

sudo nano /etc/redis/redis.conf

replace the following line

# requirepass foobared


# requirepass MYNEWPASSWORD

where MYNEWPASSWORD is a secure password of at least 64 characters, achievable with the openssl command

openssl rand 64 | openssl base64 -A
WARNING. If you follow our guide toinstall Redis Object Cache on WordPress it is important NOT rename the Redis commands as they would make Redis not compatible with the plugin.

All that remains is to rename the Redis commands that might be dangerous, adding after the comments in the section

# Command renaming

at least the following substitutions

rename-command CONFIG CONFIG_NEW
rename-command DEBUG DEBUG_NEW
rename-command FLUSHDB FLUSHDB_NEW

N.B. Replace all new command strings with the desired strings.

save the configuration file and restart the redis services

sudo systemctl restart redis

Source :

Redis Installation Quote on Linux Ubuntu

    Contact us for a free quote