• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Redis

othmaqsa

Regular Pleskian
Server operating system version
Ubuntu 20.04.6 LTS
Plesk version and microupdate number
Version 18.0.60
Hello,

Can I install Redis trough Docker ?

Is it worth it ?

Is the license are required for Docker ?

I have this notice also in my WP Dashboard:

Performance
You should use a persistent object cache
A persistent object cache makes your site’s database more efficient, resulting in faster load times because WordPress can retrieve your site’s content and settings much more quickly.
Your hosting provider can tell you if a persistent object cache can be enabled on your site. Your host appears to support the following object caching services: Redis.


Thanks.
 
Hello @AYamshanov ,

Yes, I have already seen article you sent me, but as the date of publication is old, I just wanna be sure before install anything.

Thank you for the confirmation.
 
@AYamshanov

For the variables REDIS_MASTER_HOST, I need to put the locahost address 127.0.0.1, right ?

As the redis port is 6379, should I open it or can I keep this port closed ?
 
If you have Docker Extension installed.

You can simply run,

Code:
#docker run --name=redis --sysctl net.core.somaxconn=511 -p 127.0.0.1:6379:6379 redis

If you would like to edit the Redis config file, you can Map it to a local folder.

Code:
#
docker run --name=redis --sysctl net.core.somaxconn=511 -v /root/redis/conf:/usr/local/etc/redis -p 127.0.0.1:6379:6379 redis redis-server /usr/local/etc/redis/redis.conf

Since the above commands are binding the Redis to the localhost, there is no need to have a password I guess.

You should be able to do the above using the Plesk interface as well.
 
Hello @WebHostingAce ,

Thank you for your help.

Still I need to add the following lines in the wp-config.php for every websites ?

define( 'WP_CACHE_KEY_SALT', 'example.com:' );

define( 'WP_REDIS_PASSWORD', 'redispassword' );
 
If you have Docker Extension installed.

You can simply run,

Code:
#docker run --name=redis --sysctl net.core.somaxconn=511 -p 127.0.0.1:6379:6379 redis

If you would like to edit the Redis config file, you can Map it to a local folder.

Code:
#
docker run --name=redis --sysctl net.core.somaxconn=511 -v /root/redis/conf:/usr/local/etc/redis -p 127.0.0.1:6379:6379 redis redis-server /usr/local/etc/redis/redis.conf

Since the above commands are binding the Redis to the localhost, there is no need to have a password I guess.

You should be able to do the above using the Plesk interface as well.
When I run the second cmd, this error occur: can't open config file '/usr/local/etc/redis/redis.conf': No such file or directory

Can you help please ?
 
The second is only if you want to have the redis.conf file on the local disk in root/redis/conf directory.

If you do not want to edit redis default configuration, you can simply run the first command. In most case this should be ok.
 
@WebHostingAce , I can see there is no mapping in the container, so no persistant cache is configured..
I have tried to map bitnami to var/redis but this error occur after starting the container
Initializing Redis
mkdir: cannot create directory '/bitnami/redis': Permission denied
 
@WebHostingAce , I can see there is no mapping in the container, so no persistant cache is configured..

Sorry, I do not understand the above.

In this article How to Optimize WordPress with Redis and Docker - Plesk Guide , they have used bitnami/redis. I'm not sure if there is a specif reason to use bitnami/redis.

I tried with a

#docker run --name=redis --sysctl net.core.somaxconn=511 -p 127.0.0.1:6379:6379 "redis:5.0.0"

It seems to be working.

Firefox_Screenshot_2024-08-22T08-36-46.070Z.png

Since there is no password to this Redis. I only added

define( 'WP_CACHE_KEY_SALT', 'example.com:' );

(Change the domain but keep the : )

to the wp-config.php
 
Thank you @WebHostingAce

I'll use the second method:
// adjust Redis host and port if necessary
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );

// change the prefix and database for each site to avoid cache data collisions
define( 'WP_REDIS_PREFIX', 'my-moms-site' );
define( 'WP_REDIS_DATABASE', 0 ); // 0-15

// reasonable connection and read+write timeouts
define( 'WP_REDIS_TIMEOUT', 1 );
define( 'WP_REDIS_READ_TIMEOUT', 1 );
Just to confirm:
define( 'WP_REDIS_DATABASE', 0 ); // 0-15
The 1 first value will be 0 for the 1st website, the second one will 1 etc... right ?
You should be able use the same container with,

define( 'WP_CACHE_KEY_SALT', 'example.com:' );
or
define( 'WP_REDIS_PREFIX', 'my-site' );

Please see redis-cache/INSTALL.md at develop · rhubarbgroup/redis-cache

I have noticed one issue with this Plugin so far. It FLUSHALL all redis data regardless which website you are the "Flush Cache" from.
 
I have noticed one issue with this Plugin so far. It FLUSHALL all redis data regardless which website you are the "Flush Cache" from.
Isn't that by design? I think you'd need to use separate redis instances if you want to avoid this.
 
Isn't that by design? I think you'd need to use separate redis instances if you want to avoid this.

I haven't tried to use the same Redis and different databases for different websites.

define( 'WP_REDIS_DATABASE', 0 ); // 0-15
 
Ok.. I tested this.

by using different Redis Databases will solve the previous issue I mentioned.

Eg -

Website 1 - define( 'WP_REDIS_DATABASE', 0 );

Website 2 - define( 'WP_REDIS_DATABASE', 1 );

Website 3 - define( 'WP_REDIS_DATABASE', 2 );

Now when you "Flash Cache" from Website 2, the website 1 and 3 Redis Cache will remain.

I do not think we need the followings. 1. The Plugin creates random Prefixes 2. We will be using different Redis Databases.

define( 'WP_CACHE_KEY_SALT', 'example.com:' );

or

define( 'WP_REDIS_PREFIX', 'my-site' );
 
  • Like
Reactions: mow
Back
Top