4.5. REDIS SERVER INSTALLATION
4.5.1. On Terminal, type:
sudo apt install redis-server redis-tools
redis-cli -v
4.5.2. Restart the Redis server to make sure it is running
sudo service redis-server restart
4.5.3. Execute a simple Redis command to verify your Redis server is running and available:
redis-cli
On Redis-cli (127.0.0.1:6379>), type:
set user:1 "Jane"
get user:1
4.5.4. Configure a Redis Password
sudo nano /etc/redis/redis.conf
Scroll to the SECURITY section and look for a commented directive that reads:
# requirepass foobared
Uncomment it by removing the #, and change foobared to a secure password.
To generate a strong password for Redis-server:
openssl rand 60 | openssl base64 -A
To test that the password works, access the Redis command line:
redis-cli
The following shows a sequence of commands used to test whether the Redis password works. The first command tries to set a key to a value before authentication:
set key1 10
That won’t work because you didn’t authenticate, so Redis returns an error:
(error) NOAUTH Authentication required.
The next command authenticates with the password specified in the Redis configuration file:
auth <your_redis_password>
Output:
OK