Skip to main content

PHP LSAPI Overview

Learning Focus

By the end of this lesson you will understand what LSAPI is, how it connects OpenLiteSpeed to PHP, and why it performs better than alternatives like CGI or FastCGI.

What LSAPI Is

LSAPI (LiteSpeed Server Application Programming Interface) is LiteSpeed's native interface for running PHP processes efficiently. It is the bridge between OpenLiteSpeed and the lsphp binary.

How LSAPI Compares to Alternatives

InterfaceProcess LifecycleOverheadPerformance
CGINew process per requestVery highSlowest
FastCGIPersistent processes via socketModerateGood
LSAPIPersistent processes, tight integrationLowBest with OLS
PHP-FPMPersistent pool, industry standardModerateGood (designed for Nginx/Apache)

Why LSAPI Performs Well

  • Worker reuse: PHP workers persist between requests, avoiding process creation overhead
  • Shared memory: LSAPI uses shared memory for data transfer when possible
  • Tight coupling: The protocol is designed specifically for LiteSpeed, reducing translation overhead
  • Auto-management: OpenLiteSpeed can spawn, manage, and recycle PHP workers automatically

How It Works in Practice

  1. A PHP request arrives at OpenLiteSpeed
  2. The script handler matches the .php extension to an external app
  3. The external app definition points to the lsphp binary
  4. OpenLiteSpeed communicates with lsphp via the LSAPI protocol
  5. The lsphp worker executes the PHP code and returns the response
  6. The worker stays alive for the next request
# Check if lsphp workers are running
ps aux | grep lsphp | grep -v grep

# Check the external app definition
grep -A 10 "extprocessor" /usr/local/lsws/conf/httpd_config.conf
info

When people say OpenLiteSpeed is strong for PHP, LSAPI is a big part of the reason. It is the core technology that makes PHP execution efficient on LiteSpeed servers.

Key Takeaways

  • LSAPI is LiteSpeed's native PHP interface — purpose-built for performance.
  • It reduces overhead compared with CGI or even FastCGI by keeping workers persistent and tightly integrated.
  • You do not need PHP-FPM with OpenLiteSpeed — lsphp via LSAPI is the standard approach.

What's Next