Help Docs Server Administration Linux Server Administration Apache Web Server mod_lsapi

mod_lsapi

Boost Apache PHP speed with `mod_lsapi` on EasyApache 4. LiteSpeed's handler offers faster performance & lower memory use, even without LiteSpeed Web Server.

Using mod_lsapi with EasyApache 4 (without LiteSpeed)

Overview

mod_lsapi is LiteSpeed Technologies’ high-performance PHP handler, now available on EasyApache 4, even if LiteSpeed is not installed. It works similarly to FCGI, but instead of Apache managing the PHP processes, mod_lsapi uses independent backend pools. This improves performance and memory handling.

It’s especially useful for servers that want better PHP speed without switching to LiteSpeed or using suPHP.

Why Use mod_lsapi?
  • Faster than suPHP and FCGI
  • Lower memory usage due to smart process handling
  • Supports opcode caching and persistent PHP processes
  • Compatible with CageFS and CloudLinux PHP Selector
Installation

To install mod_lsapi on CentOS with EasyApache 4:

yum install ea-apache24-mod_lsapi
Note

You do not need LiteSpeed installed. This package works with Apache under EA4.

Configuration
Default configuration file
  • Do not edit:
    /etc/apache2/conf.d/lsapi.conf
  • Custom changes should go in:
    /etc/apache2/conf.d/includes/pre_virtualhost_global.conf
Example custom configuration

Add the following block to control the number of PHP backend children and their idle timeout:

<IfModule lsapi_module>
lsapi_backend_children 20
lsapi_backend_max_idle 3
</IfModule>

Recommendations:

  • lsapi_backend_children: Increase this based on your server’s available RAM.
  • lsapi_backend_max_idle: Reduce idle time to lower memory use (default: 300 seconds).

Important directives
lsapi_backend_children
  • Max child PHP processes per domain.
  • Default: 5
  • Logs error if limit is hit: arduinoCopyEditReached max children process limit: 5...

lsapi_backend_max_process_time

  • Max request processing time (in seconds).
  • Default: 300
  • If exceeded, logs will show: vbnetCopyEditError... timeout 300 is exceeded Killing runaway process...

Also, ensure Timeout in Apache config is high enough for long-running tasks.

Logging
  • mod_lsapi error log:
    /var/log/apache2/lsphp-stderr.log
  • General Apache error log (timeout messages):
    /var/log/apache2/error_log
CloudLinux integration
  • Fully supported with CloudLinux + CageFS + PHP Selector + alt-php
  • Run this after updating PHP module selections:
/usr/bin/switch_mod_lsapi --build-native-lsphp
Per-Folder PHP versions

mod_lsapi: Limited to 2 PHP versions per account (due to persistent processes)
Use only if the default handler is set to FCGI

suPHP (CloudLinux): No limit on versions

Reference: Official Documentation

Summary

mod_lsapi is a high-performance PHP handler by LiteSpeed, available for EasyApache 4 without requiring LiteSpeed itself. It offers faster execution and lower memory usage than suPHP or FCGI by using independent PHP process pools. It supports CloudLinux, CageFS, and PHP Selector, with limited support for multiple PHP versions per account.

Was this article helpful?