How to Install OpenLiteSpeed with DirectAdmin

As of DirectAdmin 1.57 and running CustomBuild 2.0, you can now install OpenLiteSpeed. OpenLiteSpeed is the Open Source edition of LiteSpeed Web Server Enterprise. OpenLiteSpeed contains all of the essential features found in LiteSpeed Enterprise, including full use of the LiteSpeed Cache (LSCache) for WordPress plugin. It is developed and maintained by the same LiteSpeed development team.

Using OpenLiteSpeed provides your server with less overhead with all processes being Event driven, is fully mod_rewrite compatible, with no new syntax to learn and you can continue to use your existing rewrite rules. Features include Anti-DDoS connection and bandwidth throttling, ModSecurity v3 integration, Built-in full-page cache module, Automatic implementation of Google’s PageSpeed with mod_pagespeed. You can find out more about OpenLiteSpeed’s features here.

OpenLiteSpeed although lacks the automatic reloading of OpenLiteSpeed when editing the .htaccess file. However, we will cover that off at the bottom of this guide. When used with DirectAdmin you will not have the ability to manage OpenLiteSpeed through the WebAdmin GUI as it is setup in read only mode. You will have to configure OpenLiteSpeed using custom templates.

Install OpenLiteSpeed

You can install OpenLiteSpeed by changing the WEB Server Settings in DirectAdmin’s options.conf file or run the following commands:

cd /usr/local/directadmin/custombuild
./build update
./build set webserver openlitespeed
./build set mod_ruid2 no
./build set php1_mode lsphp
./build set php1_release 7.2
./build openlitespeed
./build php n
./build rewrite_confs

If you want to install more than one PHP version such as 7.2, 7.3 and 7.4, you can use the following commands:

cd /usr/local/directadmin/custombuild
./build update
./build set webserver openlitespeed
./build set mod_ruid2 no
./build set php1_mode lsphp
./build set php1_release 7.2
./build set php2_mode lsphp
./build set php2_release 7.3
./build set php3_mode lsphp
./build set php3_release 7.4
./build openlitespeed
./build php n
./build rewrite_confs

Check Installation

Now to check to make sure OpenLiteSpeed installed correctly, open your favourite browser and enter your server’s IP address or FQDN (server.domain.com) in the address bar. Once connected you should see the message OpenLiteSpeed is functioning normally in the top left of the screen. If you don’t you receive this message please check the settings above and reinstall OpenLiteSpeed.

Automatically Reload mod_rewrite Rules

OpenLiteSpeed will only load mod_rewrite rules from .htaccess at startup only. To get around this you will need to add a cron task to reload OpenLiteSpeed automatically. By using the cron script below every time you edit a .htaccess file DirectAdmin will reload OpenLiteSpeed automatically so the new rewrite rules can take effect immediately.

echo '*/3 * * * * root if ! find /home/*/domains/*/*_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name ".htaccess" -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi' > /etc/cron.d/openlitespeed_htaccess_scan

The cron task will scan for .htaccess files in public/private_html folders, using a max depth of 2 folders -maxdepth 2. The folder depth can be changed to 3 or more by changing the
-maxdepth code to 3. Please note this will slow down scanning and could impact server performance.

You can check to ensure the file has been created by using the following command:

cat /etc/cron.d/openlitespeed_htaccess_scan

That’s it. You have now installed successfully install OpenLiteSpeed with DirectAdmin on your server. Checked the installation to ensure everything is working as it should and enabled the automatic reload of OpenLiteSpeed to ensure any mod_rewrite rules changes in your .htaccess file takes effect immediately.

How useful was this guide?

Click on a star to rate it!

Average rating / 5. Vote count:

Be the first to rate this guide.

We are sorry that this guide was not useful for you!

Help us to improve this guide!

Tell us how we can improve this guide?

By VPSBasics

This guide was written by the VPS Basics editorial team, led by Gilberto Van Roosen. They are a unique blend of people, dedicated to providing highly detailed, comprehensive and importantly easy to follow tutorials, written in plain English. They specialise in tutorials for managing Linux servers and its software.

Join the Conversation

Note: Your email address will not be published when posting a comment.

Note: All comments are held for moderation and are reviewed by our editorial team prior to approval.

VPSBasics uses Akismet anti-spam filters to reduce spam across our website. Our website is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Learn how your data is processed.