2023-09-13 14:59:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-09-13 14:58:44 +00:00
|
|
|
cd /var/www/webroot/ROOT
|
2023-09-13 14:59:28 +00:00
|
|
|
|
2023-09-13 17:48:42 +00:00
|
|
|
# check if litespeed cache is enabled
|
|
|
|
|
|
|
|
litespeed_enabled=$(wp plugin is-active litespeed-cache)
|
|
|
|
|
|
|
|
# disable object caching if so
|
2023-09-13 18:06:55 +00:00
|
|
|
if [ -n "$litespeed_enabled" ]; then
|
2023-09-13 17:48:42 +00:00
|
|
|
wp litespeed-option set object 0
|
|
|
|
fi
|
2023-09-13 14:59:28 +00:00
|
|
|
|
|
|
|
#install OCP instead
|
2023-09-13 17:48:42 +00:00
|
|
|
wp plugin install 'https://objectcache.pro/plugin/object-cache-pro.zip?token=091801712a649241ca11668fdf19552c2d13dad4d9b1d28848c276cd5111' --force --activate
|
|
|
|
|
2023-09-13 18:06:55 +00:00
|
|
|
# config OCP
|
2023-09-13 17:48:42 +00:00
|
|
|
|
2023-09-13 18:06:55 +00:00
|
|
|
# TODO check if is a cluster and get port,
|
2023-09-13 17:48:42 +00:00
|
|
|
|
2023-09-13 18:06:55 +00:00
|
|
|
is_cluster=false
|
|
|
|
|
|
|
|
if $is_cluster; then
|
|
|
|
host=IP.ADD.HERE
|
|
|
|
port=6379
|
|
|
|
password="password from end of redis node conf file"
|
|
|
|
else
|
|
|
|
# use default single-node configuration
|
|
|
|
host=/var/run/redis/redis.sock
|
|
|
|
port=0
|
|
|
|
fi
|
2023-09-13 17:48:42 +00:00
|
|
|
|
2023-09-13 18:06:55 +00:00
|
|
|
ocp_config="[
|
2023-09-13 17:48:42 +00:00
|
|
|
'token' => '091801712a649241ca11668fdf19552c2d13dad4d9b1d28848c276cd5111',
|
2023-09-13 18:06:55 +00:00
|
|
|
'host' => '$host',
|
|
|
|
'port' => $port,
|
2023-09-13 17:48:42 +00:00
|
|
|
'client' => 'relay',
|
|
|
|
'database' => 0,
|
|
|
|
'prefix' => 'db0',
|
|
|
|
|
|
|
|
// whether multiple WordPress sites use the Redis instance
|
2023-09-13 18:06:55 +00:00
|
|
|
'shared' => false,
|
2023-09-13 17:48:42 +00:00
|
|
|
|
|
|
|
// reduce memory usage
|
|
|
|
'compression' => 'zstd',
|
|
|
|
'serializer' => 'igbinary',
|
|
|
|
|
|
|
|
// experiment with these, some sites may benefits, so may not
|
|
|
|
'prefetch' => false,
|
|
|
|
'split_alloptions' => false,
|
|
|
|
|
|
|
|
// standard options
|
|
|
|
'timeout' => 0.5,
|
|
|
|
'read_timeout' => 0.5,
|
|
|
|
'retries' => 3,
|
|
|
|
'backoff' => 'smart',
|
|
|
|
|
|
|
|
// debug only
|
|
|
|
'debug' => false,
|
|
|
|
'save_commands' => false,
|
2023-09-13 18:06:55 +00:00
|
|
|
]"
|
2023-09-13 17:48:42 +00:00
|
|
|
|
2023-09-13 18:14:07 +00:00
|
|
|
wp config set WP_REDIS_CONFIG "$ocp_config" --raw
|
2023-09-13 18:06:55 +00:00
|
|
|
wp config set WP_REDIS_DISABLED false --raw
|
2023-09-13 18:56:07 +00:00
|
|
|
wp redis enable --force
|
|
|
|
wp redis flush
|
2023-09-13 17:48:42 +00:00
|
|
|
|
2023-09-13 18:06:55 +00:00
|
|
|
# free redis object cache config
|
|
|
|
#wp config set WP_REDIS_CLIENT 'relay'
|
|
|
|
#wp config set WP_REDIS_SCHEME 'unix'
|
|
|
|
#wp config set WP_REDIS_IGBINARY true --raw
|
|
|
|
#wp config set WP_REDIS_PATH '/var/run/redis/redis.sock'
|
|
|
|
#wp config set WP_REDIS_PORT 0 --raw
|
|
|
|
#wp config set WP_REDIS_DATABASE 0 --raw
|
2023-09-13 18:52:22 +00:00
|
|
|
|
2023-09-13 14:59:28 +00:00
|
|
|
|