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
| Interface | Process Lifecycle | Overhead | Performance |
|---|---|---|---|
| CGI | New process per request | Very high | Slowest |
| FastCGI | Persistent processes via socket | Moderate | Good |
| LSAPI | Persistent processes, tight integration | Low | Best with OLS |
| PHP-FPM | Persistent pool, industry standard | Moderate | Good (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
- A PHP request arrives at OpenLiteSpeed
- The script handler matches the
.phpextension to an external app - The external app definition points to the
lsphpbinary - OpenLiteSpeed communicates with
lsphpvia the LSAPI protocol - The
lsphpworker executes the PHP code and returns the response - 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 —
lsphpvia LSAPI is the standard approach.
What's Next
- Continue to Process Management to learn how PHP worker lifecycle is controlled.