How to Setup Redis for Magento 2.4?

After we successfully installed Redis, if we run:
redis-cli

We will get the following errors:
-bash: redis-cli: command not found

Run the following command, and we will find the location of the command of redis-cli
which redis-cli
/usr/local/redis/bin/redis-cli

Just add ‘/usr/local/redis/bin’ to Environment Variables in Linux

How to Set and List Environment Variables in Linux?

echo $PATH

This command will list Environment Variables in Linux.

How to add ‘/usr/local/redis/bin’ to Environment Variables in Linux, then?

#vi ~/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/redis/bin
export PATH

Save and exit.

Run:
source ~/.bash_profile

The newly added Environment Variable will be active right away.

Now we can run redis-cli successfully.

———————————————
Use Redis for the Magento page and default cache

bin/magento setup:config:set –cache-backend=redis –cache-backend-redis-server=127.0.0.1 –cache-backend-redis-db=0

bin/magento setup:config:set –page-cache=redis –page-cache-redis-server=127.0.0.1 –page-cache-redis-db=1

———————————————-
Redis monitor command
In a command prompt on the server on which Redis is running, enter:

redis-cli monitor

=================

More: digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-centos-8