This is an old revision of the document!


Web Cache Web Server Configuration - cPanel/WHM Multi-Site/Shared Hosting

This guide assumes that you have command-line access to the WHM Server. If you do not have command-line access, please refer to cPanel's documentation on editing Apache configuration files through the WHM GUI.

Simply run the following script, which will set server level and virtual host level cache roots and cache policies:

bash <(curl http://www.litespeedtech.com/packages/lscache/set_cache_root_policy.sh)

Please bear in mind that the script doesn't enable the cache lookup for user, you can either use LiteSpeed WP Cache management tools to manage it in bulk (Management tool will add CacheLookup directive to related .htaccess files) , or add cache lookup directive to .htaccess for any particular user manually by either server administrator or user himself.

<IfModule LiteSpeed>
  CacheLookup public on
</IfModule>

The following wiki explain steps in details to set cache root and cache policy manually, though there is no such need if the above script has been run already.

Set Server level cache root

Add the following content to /usr/local/apache/conf/includes/pre_main_global.conf for EA3 or /etc/apache2/conf.d/includes/pre_main_global.conf for EA4

<IfModule Litespeed>
CacheRoot /home/lscache/
</IfModule>

Note: It is recommended that you set the server level cache root to /home/lscache/ or a disk partition with enough space. Server level cache root will only be used when a vhosts cache root is not set.

Set Virtual Host level cache root for all VHosts

Create a file named lscache_vhosts.conf in the /usr/local/apache/conf/userdata/ for EA3 and /etc/apache2/conf.d/userdata/ for EA4 (if this directory does not exist, create it) with the following content:

<IfModule Litespeed>
  CacheRoot lscache
</IfModule>

This is done to set cache directory for all Virtual Hosts in their home directory (/home/<user>/lscache).

Apply these changes to all Virtual Hosts by running the following command:

/scripts/ensure_vhost_includes --all-users

Note: You only need to run this command once and it will activate for all users, including new users created by WHM later. No need to edit the cpanel skeleton file.

Set Virtual Host level cache root for a single VHost

Example: Apache 2.2 installations with an HTTP site

Create a file named lscache_vhost.conf in the /usr/local/apache/conf/userdata/std/2_2/<user>/<domain>/ directory for EA3 or /etc/apache2/conf.d/userdata/a/std/2_2/<user>/<domain>/ directory for EA4 (if this directory does not exist, create it) with the following contents:

<IfModule Litespeed>
CacheRoot lscache
</IfModule>

This is done to set the cache directory for this Virtual Host to /home/<user>/lscache.

Apply these changes to this Virtual Host by running the ensure_vhost_includes script with the following command:

/scripts/ensure_vhost_includes --user=$user

For HTTPS sites or Apache 2.4 installations, please refer to cPanels documentation on modifying virtual host containers with include files.

Note: If different vhosts share the same document root, these vhosts have to share the same vhost level cache root directory.

After applying your cache storage settings, perform a graceful restart of LiteSpeed Web Server to have these changes take effect. LiteSpeed Web Server will automatically create cache root directories with proper permission. Users don't need to manually create any cache root directories themselves.

service lsws restart

The default LiteSpeed Cache settings work well with most caching scenarios. If you're configuring a shared hosting environment, don't change any of the Server Level default cache policy settings. Leave them as Not Set.

Cache Policy:
Enable Public Cache:Not Set
Check Public Cache:Not Set
Max Object Size:Not Set
Cache Expire Time (seconds):Not Set
Cache Stale Age (seconds)Not Set
Cache Request with Query String:Not Set
Cache Request with Cookie:Not Set
Cache Response with Cookie:Not Set
Ignore Request Cache-Control:Not Set
Ignore Response Cache-Control:Not Set
Enable Private Cache:Not Set
Check Private Cache:Not Set
Private Cache Expire Time (seconds):Not Set

Add the following Apache style configuration directive in your application level .htaccess file to enable cache lookup.

<IfModule LiteSpeed>
  CacheLookup public on
</IfModule>

Note: If you are enabling LiteSpeed Cache through our WHM Plugin, you may skip this step since LSCache Management tool will add CacheLookup to .htaccess for you.

For Advanced Cache Configuration info, look here.

  • Admin
  • Last modified: 2016/08/25 20:34
  • by Jackson Zhang