Set Up Cache Root and Enable LiteSpeed Cache Throughout the Server¶
Cache Storage Settings¶
Set Server-Level Cache Root¶
Add the following lines to the
<IfModule Litespeed> CacheRoot /home/lscache </IfModule>
It is recommended that you set the server-level cache root to
/home/lscache/ or a disk partition with enough space. Please never set cache root to
Set Virtual-Host-Level Cache Root for all Virtual Hosts¶
<IfModule Litespeed> CacheRoot lscache </IfModule>
This is done to set each Virtual Hosts' cache directory to its home directory (
Apply these changes to all Virtual Hosts by running the following command:
cd /usr/local/directadmin/custombuild ./build rewrite_confs
LiteSpeed Web Server will be restarted after running above commands.
Set up DirectAdmin LiteSpeed Plugin to manage Cache Installations¶
Download the DirectAdmin Plugin
.tgz file from here.
Log into the DirectAdmin Panel with the
admin username, or with a user which has admin-level authorizations. After you're logged in, navigate to the Plugin Manager section. It is usually located at
Click Add New.
Click Upload, and select the
.tgz file you downloaded. In the Password section, Enter your DirectAdmin user's password. Click Install.
Once the installation is complete, you should be see the Litespeed Webserver Plugin option listed among Extra Features.
Using the Plugin¶
From within the LSCWP Version Manager section, select the WordPress plugin version you'd like to install on all WordPress websites hosted on the server.
From the Manage Cache Installations section, click Scan to search the entire server for existing WordPress installations. You can also enable or disable cache for individual websites from here.
From the Mass Enable/Disable Cache section, you can Enable or Disable Cache on all scanned WordPress installations throughout the server. This is safe because it automatically skips the WordPress installations which have a different cache plugin installed.
This plugin can also be used to access the Litespeed WebAdmin Console to manage license-based functions.
Set up ModSecurity Rules for LiteSpeed with DirectAdmin¶
By default, DirectAdmin CustomBuild can install OWASP rulesets without a third party installation script. You can run the following commands to enable ModSecurity and install OWASP rules automatically:
cd /usr/local/directadmin/custombuild ./build set modsecurity yes ./build set modsecurity_ruleset owasp ./build modsecurity
If you prefer Comodo WAF, DA CustomBuild may call the Comodo client agent script to install the rule set, but you run a risk of installing the Apache ruleset instead of the LiteSpeed ruleset. (The two servers have different rulesets for Comodo WAF.) In order to avoid installing the wrong ruleset, we recommend following the Comodo WAF Quick Start Guide instead of using CustomBuild for this.
Verify LiteSpeed is Running Correctly on Websites and LiteSpeed Cache is Working¶
Now that the installation and enablement process for your server has been completed, it's time to verify that your websites are running on LiteSpeed and that LiteSpeed Cache is working correctly on your WordPress websites.
Select User Level and Click Domain Setup and open any customer’s website, and check its headers, like so:
The headers should show Server as
LiteSpeed and X-LiteSpeed-Cache as
The X-LiteSpeed Cache header will only be shown on Websites which have LiteSpeed Cache enabled at that moment. Other websites will show Server as
LiteSpeed only, and will continue to use benefits provided by LiteSpeed without caching.
Headers can be checked by using browser extensions.
Set Up Default PHP Version¶
When DirectAdmin sets up an Apache virtual host, it does not set a PHP handler version, and Apache uses
php1 by default in the absence of a specified PHP version. LiteSpeed, on the other hand, does not use
php1 as the default PHP version when there is no PHP version specified. You will need to set up a default PHP version for LiteSpeed through the LiteSpeed WebAdmin Console.
Log into LSWS WebAdmin Console, navigate to Configuration > Server > PHP, and set Default PHP Versions to
xx is the PHP version you wish to use.
php74 for PHP v7.4
Default PHP Versions is a generic PHP handler customization, and is not specific to DirectAdmin. It applies to all control panels and to standalone installation. cPanel or Plesk may override the default through Apache
httpd.conf, but DirectAdmin relies only on this setting, as it has no PHP handler override for Apache.
Set Up Multiple PHP Versions¶
DirectAdmin CustomBuild allows multiple PHP versions when you build PHP. In
/usr/local/directadmin/custombuild/options.conf, you can build four diferent php versions using
php4_release. Once they have been built, any type of handler, such as lsphp, php-fpm, fastcgi, etc., will be stored in
php1_release will be the default PHP version unless it is overridden by the
In the DirectAdmin Control Panel, you can choose a domain's PHP version from the list in the DA PHP Selector at the domain level configuration.
Select User Level, click Domain Setup, and select any website from the list. Head over to the PHP Version Selector option and select the desired PHP Version. Press the Save button.
After a PHP version such as
php72 is selected, DirectAdmin will write the handler configuration to the domain's virtual host Apache confgiguration, like so:
How to Use CloudLinux PHP Selector with DirectAdmin¶
When you install CloudLinux and CloudLinux PHP Selector to Direct Admin, both CloudLinux PHP Selector and DA PHP Selector will take effect. CloudLinux PHP selector is per-user, while DA PHP Selector is per-domain. DA PHP Selector always overrides PHP version at the domain level. If you don't use DA PHP Selector on a domain, then CloudLinux PHP Selector is in effect.
If you, as a user, select
php73 in Cloud Linux PHP Selector, you may still select
php56 for one or more domains under your user account.
The CloudLinux PHP Selector interface can be found at the user level after login, under Advanced Features > Select PHP Version.
According to DirectAdmin documentation, if you're running CloudLinux and have
php1_mode=lsphp, you'll be able to use the CloudLinux PHP Selector plugin.
If you also use the DirectAdmin PHP selector, the CloudLinux selection only takes effect if the domain is using the first DA PHP instance.
CloudLinux documentation notes: to prevent DirectAdmin PHP Selector from interfering with CloudLinux PHP Selector, you need to have only one PHP version built on the server with CustomBuild.
While the linked documentation above deals with Apache, LiteSpeed Web Server will work the same way.
In any case, if there is any interference between CloudLinux PHP Selector and DirectAdmin PHP Selector, and you cannot work out the correct overriding logic between DA and CL, you can simply force LiteSpeed to use the CloudLinux PHP Selector by adding the following to .htaccess
<IfModule LiteSpeed> AddHandler application/x-httpd-phpsel .php </IfModule>
More specifically, you can override to a particular
alt-php version such as
php74 by adding the following to .htaccess:
<IfModule LiteSpeed> AddHandler application/x-httpd-alt-php74 .php </IfModule>
Control HTTP/2 and HTTP/3 via Apache Config¶
You can enable and disable a variety of protocols in
httpd.conf, using the
Disable all protocols
<IfModule LiteSpeed> SpdyEnabled off </IfModule>
Enable HTTP protocols and disable everything else
<IfModule LiteSpeed> SpdyEnabled http2 http3 </IfModule>
HTTP protocols are enabled by default, while SPDY protols are disabled by default.
| ||Enable SPDY/2||Disabled|
| ||Enable SPDY/3||Disabled|
| ||Enable HTTP/2||Enabled|
| ||Enable HTTP/3||Enabled|
| ||Disable all protocols|
When you use this directive to explicitly enable one or more protocols, anything not selected will be disabled. For example,
SpdyEnabled http2 will enable HTTP/2, while SPDY/2, SPDY/3 and HTTP/3 will be disabled. Be careful not to inadvertantly disable a protocol you wanted to use!
Switch Between Apache and LiteSpeed¶
If you have a need to switch between Apache and LiteSpeed you may use the following commands: