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)

Note that this script doesn't enable cache lookup for users, you can either use the LiteSpeed WordPress Cache Management tools in the LiteSpeed WHM Plugin to manage this in bulk (the management tools will add the CacheLookup directive to the related .htaccess files), or add the CacheLookup directive to .htaccess files for individual users manually. This can be done by either the server administrator or the user themselves by adding the following lines:

<IfModule LiteSpeed>
  CacheLookup public on
</IfModule>

Note: The steps that follow will guide you through manually setting cache root and cache policy settings. If the above script has already been run, there is no need to follow these steps.

Set Server level cache root

Add the following lines to the /usr/local/apache/conf/includes/pre_main_global.conf file for EA3 or the /etc/apache2/conf.d/includes/pre_main_global.conf file 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.

Set Virtual Host level cache root for all Virtual Hosts

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

<IfModule Litespeed>
  CacheRoot lscache
</IfModule>

This is done to set the 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 lines:

<IfModule Litespeed>
CacheRoot lscache
</IfModule>

This will 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 cPanel's 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.

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 as below:

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 document root .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 enabling cache lookup manually as the LiteSpeed Cache Management tool will add CacheLookup to .htaccess files for you.

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 permissions. Users don't need to manually create any cache root directories themselves.

service lsws restart

For Advanced Cache Configuration info, look here.

  • Admin
  • Last modified: 2016/11/03 14:33
  • by Rob Holda