When setting up PHP Redis in a way like Digital Ocean on a localhost, you might get this error:
Fatal error: Uncaught RedisException: ERR AUTH
We assume your PHP script starts like this:
<?php
$redisPassword = "";
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->auth($redisPassword);
Because this is a localhost, we do not need a password for Redis. That is why we also do not need to use the $redis->auth() part. We can leave this out.
Or if you are using environment variables, you can use:
<?php
$redisPassword = "";
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
if (!empty($redisPassword)
{
$redis->auth($redisPassword);
}
If you are on a production server, it is wise to use a password, of course and not leave the $redis->auth() part out.
Happy coding!