ModLSPHP Module

How Can We Help?
< Back
You are here:


This wiki discusses how to add the LiteSpeed ModLSPHP Module on OpenLiteSpeed (mod_lsphp). The ModLSPHP module improves PHP performance while loading PHP into the currently running server process, reducing overall resource usage. This module also takes advantage of support for multi-threaded applications found in newer versions of PHP.

For this guide, we assume you already have a working installation of OpenLiteSpeed 1.5.0 RC1 or greater. Module support was made available in version 1.3 but the ModLSPHP module is only available and supported as of version 1.5.0 RC1. The ModLSPHP module is not added to OpenLiteSpeed installations automatically and must be built.

Note: As this is still an RC release module some strange behavior may be observed. If any bugs are encountered while using this module, please do not hesitate to report them. Thank you!

Installing The LiteSpeed ModLSPHP Module

Download The LiteSpeed ModLSPHP Module

Download and install OpenLiteSpeed 1.5.0 RC1 or higher if you have not done so already.

The ModLSPHP Module is available as of OpenLiteSpeed version 1.5.0 RC1 and, at the time of this writing, uses a custom built version of PHP 7.2.1.

Build The LiteSpeed ModLSPHP Module

Go into the ModLSPHP Module directory /openlitespeed_download/src/modules/mod_lsphp and run the script.

cd /openlitespeed_download/src/modules/mod_lsphp

Should any dependency issues arise, please install said dependencies now and re-run the script.

Once the build script has completed, you will notice the following:

  • A newly-created PHP directory located in the same directory as openlitespeed_download.
  • A newly-created phpdbg directory located parallel to the aforementioned PHP directory.
  • A symbolic link in the current directory, pointing to in the aforementioned PHP directory.

At this point you may optionally copy/create a php.ini file for use with mod_lsphp and place it in the phpdbg/php-7.2/lib64 directory.

Add The Module To The Modules Directory

To add the module to OpenLitespeed, the symbolic link created at the end of the last step should be re-created in OpenLiteSpeed’s modules directory. For this example we will assume the default OpenLiteSpeed location of /usr/local/lsws with symbolic link pointing to /usr/local/php-7.2/libs/

cd /home/user/lsws/modules
ln -s /usr/local/php-7.2/libs/

Set up the module

Now that the module has been added to the OpenLiteSpeed modules directory, we can configure it to be used through the WebAdmin Console. These steps can be performed at either the server or virtual host level with virtual host level configurations taking precedence.

  1. Log into the WebAdmin Console and navigate to Server Configuration > Modules and click ‘Add’ at the top right of the screen.
  2. Fill in the ‘Module’ field with the module name, in this case mod_lsphp72, and save. The other fields on the screen can be ignored for this module.

With the module defined, we will now configure a PHP handler to use it. This can be done by either editing an existing script handler or creating a new one.

Note: If your server contains sites that may not be PHP 7 ready, a new script handler should be added with the appropriate Suffixes, such as php7.

Editing An Existing Script Handler

  1. Navigate to Server Configuration > Script Handler and click ‘Edit’ next to the current PHP script handler
  2. Change the ‘Handler Type’ to Module Handler, select the newly created mod_lsphp72 as the ‘Handler Name’, and save.

Adding A New Script Handler

  1. Navigate to Server Configuration > Script Handler and click the ‘Add’ button at the top right to create a new handler.
  2. Set the script suffix(es) that you would like handled in ‘Suffixes’. For example, suffix php7 will handle all files ending in .php7. Be careful not to use a suffix already handled by an existing script handler as the existing handler will be overwritten on save.
  3. Change the ‘Handler Type’ to Module Handler, select the newly created mod_lsphp72 as the ‘Handler Name’, and save.

Congratulations, OpenLiteSpeed should now be configured to use mod_lsphp!