Cache Redis for Users CLI¶
Using a control panel to roll out a large number of Redis installations for LiteSpeed might be too difficult. To address this, we provide a command-line interface (CLI). This can also help in installing systems where use of a control panel may be problematic.
This is done with the redis_user_action.sh program, found in /usr/local/cpanel/whostmgr/docroot/cgi/lsws/bin/.
This program must be run as root and can be used to do most everything that can be done with the Cache Redis interface. If there is an error it will return a non-zero program return code.
Tip
If you want to set—but not enable—a package for Redis you must use lspkgctl to do so. See the lspkgctl documentation for syntax and usage.
The use of this program begins with the first parameter which is an action. Additional parameters depend on the action specified.
Syntax:
./redis_user_action.sh <action> [parameters]
The following actions are available:
| Action | Description |
|---|---|
| cleanup | Stop and delete the service for a user and delete the configuration |
| cleanupsvc | Stop and delete the service for a user and preserve the configuration |
| configdel | Remove the Redis configuration file from the Redis user services and restart them |
| configupd | Add or update the Redis configuration file for the Redis user services and restart them |
| defaultsizeget | Display the default Redis configuration size |
| defaultsizeset | Create a default Redis configuration size |
| disableenablecache | Future service enable operations will not have the LiteSpeed WordPress plugin enabled |
| disablepkg | Delete all of the services for the users in a package |
| enable | Configure and activate the Redis service for one or more users |
| enablepkg | Create and start Redis services for each user referenced in a package |
| getenablecache | Return a 0 return code if setenablecache has been specified |
| getuseredis | Return a 0 return code if Redis is enabled, 1 if Valkey is enabled |
| getusevalkey | Return a 0 return code if Valkey is enabled, 1 if Redis is enabled |
| list | List running services |
| list-setup | List users which have been individually configured |
| setenablecache | All future service enable operations will cause cache to be enabled if WordPress and the plugin are installed |
| setuseredis | Sets Redis as the default cache program (unsets Valkey) |
| setusevalkey | Sets Valkey as the default cache program (unsets Redis) |
cleanup¶
./redis_user_action.sh cleanup <UID>
Stop and delete the service for a user, and delete the configuration.
| Parameter | Description |
|---|---|
<UID> | ID of user to stop the service for |
Example
Stop and delete the service and configuration for user 1011:
./redis_user_action.sh cleanup 1011
cleanupsvc¶
./redis_user_action.sh cleanupsvc <username>
Stop and delete the service for a user, and preserve the configuration.
| Parameter | Description |
|---|---|
<username> | Name of user to stop the service for |
Example
Stop and delete the service for user example:
./redis_user_action.sh cleanupsvc example
configdel¶
./redis_user_action.sh configdel
Remove the Redis configuration file from the Redis user services and restart them. No parameters.
configupd¶
./redis_user_action.sh configupd <filename>
Add or update the Redis configuration file for the Redis user services and restart them.
| Parameter | Description |
|---|---|
<filename> | Fully qualified configuration file name |
Example
Update the configuration file found at /usr/local/lsws/lsns/conf/redis.conf:
./redis_user_action.sh configupd /usr/local/lsws/lsns/conf/redis.conf
defaultsizeget¶
./redis_user_action.sh defaultsizeget
Display the default Redis configuration size. No parameters.
defaultsizeset¶
./redis_user_action.sh defaultsizeset <size>
Create a default Redis configuration size.
| Parameter | Description |
|---|---|
<size> | Size in MB |
To delete, set <size> to 0.
Example
Set default Redis configuration size to 10MB:
./redis_user_action.sh defaultsizeset 10
disableenablecache¶
./redis_user_action.sh disableenablecache
Future service enable operations will not have the LiteSpeed WordPress plugin enabled. No parameters.
disablepkg¶
./redis_user_action.sh disablepkg <package>
Delete all of the services for the users in a package.
| Parameter | Description |
|---|---|
<package> | Package name |
Example
Delete all of the service for the users in the default package:
./redis_user_action.sh disablepkg default
enable¶
./redis_user_action.sh enable <lsws-home> <username> <user-home> <size>
Configure and activate the Redis service for one or more users.
| Parameter | Description |
|---|---|
<lsws-home> | LiteSpeed Web Server home directory |
<username> | Username to enable the service for |
<user-home> | User's home directory |
<size> | Redis size in MB for this service |
The <username>, <user-home>, and <size> triplet can repeat one or more times.
Example
Activate 10MB service for the example user, and 20MB service for the example2 user:
./redis_user_action.sh enable /usr/local/lsws example /home/example 10 example2 /home/example2 20
enablepkg¶
./redis_user_action.sh enablepkg <package>
Create and start Redis services for each user referenced in a package.
| Parameter | Description |
|---|---|
<package> | Package name |
Tip
You must run lspkgctl to define the size of the package before enabling it.
Example
Create and start Redis services for each user referenced in the default package:
./redis_user_action.sh enablepkg default
getenablecache¶
./redis_user_action.sh getenablecache
Returns 0 if LiteSpeed WordPress plugin Redis enabling is active; 1 if it is not active. No parameters.
Example
In a script do an action if cache enabling is enabled:
if ./redis_user_action.sh getenablecache; then
# do some action
fi
getuseredis¶
./redis_user_action.sh getuseredis
Returns 0 if Redis is the default; 1 if Valkey is the default. No parameters.
Example
In a script do an action if Redis is enabled:
if ./redis_user_action.sh getuseredis; then
# do some action
fi
getusevalkey¶
./redis_user_action.sh getusevalkey
Returns 0 if Valkey is the default; 1 if Redis is the default. No parameters.
Example
In a script do an action if Valkey is enabled:
if ./redis_user_action.sh getusevalkey; then
# do some action
fi
list¶
./redis_user_action.sh list
List running services. No parameters.
list-setup¶
./redis_user_action.sh list-setup
List users which have been individually configured (not by default or package). No parameters.
setenablecache¶
./redis_user_action.sh setenablecache
All future service enabling operations will attempt to find WordPress and the LiteSpeed Cache plugin. If it is found, it will be configured to use the service thus removing the pressure to manually configure it. Note that this operation will be limited to the time when the service is enabled. If you want to have unconfigured services configured, use the ./validate_redis.sh program. No parameters.
setuseredis¶
./redis_user_action.sh setuseredis
Sets Redis as the default cache program, and unsets Valkey as the default program. No parameters.
setusevalkey¶
./redis_user_action.sh setusevalkey
Sets Valkey as the default cache program, and unsets Redis as the default program. No parameters.