sudo apt-get update
sudo apt-get install -y redis-server
sudo apt-get install php-redis
// The following example enables Redis page caching, sets the host to redis.example.com and assigns the database number to 1. All other parameters are set to the default value.
// To configur redis default issue
bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=redis.example.com --cache-backend-redis-db=0
//To configure redis page cache issue
bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=redis.example.com --page-cache-redis-db=1
// above will change the env.php file and add configuration for redis cache
Test Redis
1. redis-cli monitor (refresh page)
2. redis-cli ping (should log "pong" back)
Further reading: https://devdocs.magento.com/guides/v2.2/config-guide/redis/redis-pg-cache.html