Configuring mod_cdn with Litespeed


Active Member
Staff member
Hi @Émerson Felinto,

Even if you would use LiteSpeed Cache, you can automate it relatively easy by using WP-CLI, when the plugin is installed, you can get and set options within the plugin by using wp-cli lscache-admin get_options and set_options respectively.

So enabling CDN for a site could be something like:

wp-cli plugin install litespeed-cache --activate
wp-cli lscache-admin set_option cdn_ori //
wp-cli lscache-admin set_option litespeed-cache-cdn_mapping[url][0]
wp-cli lscache-admin set_option cdn true
wp-cli lscache-purge all
All it requires is that you have the CDN URL available, and the site URL available.

If using 1-click installer software, there's often a possibility to have hooks where you could execute the same commands, to make it happen during installation of WordPress for example.


Active Member
Staff member
With this command I will install WP-CLI on the site of all my clients ?
To install wp-cli, you can use the instructions here:

If you then use CloudLinux and CageFS and want to make wp-cli available for your customers within their SSH / Terminal, you'd have to add wp-cli to the allowed list of commands they can run.

To make that happen, you create the file /etc/cagefs/conf.d/wpcli.cfg with the contents:

comment=Allow wp-cli to work on the server
After this, run cagefsctl --force-update to add the script to the CageFS filesystem.

If you use cPanel/WHM, I'd use the "Mass Enable Cache" functionality within the WHM plugin to install LiteSpeed Cache plugin for the WP sites.
The remaining 4 wp-cli commands, you could script it relatively easy, wp-cli has options to get the site URL for example:

Maybe something like this:

raw_domain=$(wp option get siteurl | cut -d'/' -f3) #get URL, split by / and get 3rd field

wp lscache-admin set_option cdn_ori //$raw_domain
wp lscache-admin set_option litespeed-cache-cdn_mapping[url][0] https://cdn.$raw_domain
wp lscache-admin set_option cdn true
wp lscache-purge all