PHP LSAPI Configuration โ
LiteSpeed API (LSAPI) is the PHP execution mode used by LiteSpeed Web Server. It is significantly faster than PHP-FPM because it shares memory between the web server and PHP processes, eliminating the inter-process communication overhead of FPM sockets.
Why LSAPI is faster than PHP-FPM โ
| Mode | PHP process lifecycle | IPC overhead |
|---|---|---|
| mod_php | New process per Apache worker | None (in-process) |
| PHP-FPM | Persistent pool, Unix socket | Socket per request |
| LSAPI | Persistent pool, shared memory | Near-zero |
LSAPI workers stay running between requests (like FPM) but communicate through LiteSpeed's internal memory bus rather than a socket. For CPU-bound PHP applications, this is typically 40โ50% faster than FPM.
Checking LSAPI is active โ
# Verify LiteSpeed is using LSAPI
/usr/local/lsws/bin/lswsctrl status
# Check PHP handler in LiteSpeed config
grep -r "lsphp\|lsapi" /usr/local/lsws/conf/httpd_config.confIn WHM, verify under Software โ MultiPHP Manager โ PHP versions should show as ea-php82 (EasyApache) running through LSAPI.
Configuring LSAPI worker processes โ
Edit the LSAPI configuration in the LiteSpeed WebAdmin console (https://YOUR_IP:7080):
Server โ External App โ lsphp (or the specific PHP version):
| Setting | Default | Recommended for high traffic |
|---|---|---|
| Max Connections | 35 | 100โ200 |
| Initial Request Timeout | 60s | 60s |
| Retry Timeout | 0 | 0 |
| Persistent Connection | Yes | Yes |
| Auto Start | Yes | Yes |
Per-account PHP settings โ
For cPanel servers, LSAPI respects php.ini values set through:
- cPanel โ Software โ MultiPHP INI Editor โ GUI for common settings
.htaccessdirectives โphp_value,php_flag- Custom
php.iniin the document root
# Create a custom php.ini for a specific account
cat > /home/username/public_html/php.ini << EOF
memory_limit = 512M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
opcache.enable = 1
opcache.memory_consumption = 128
opcache.max_accelerated_files = 10000
EOFOPcache tuning โ
OPcache is critical for PHP performance โ it caches compiled bytecode so PHP files don't need to be parsed on every request.
; Recommended OPcache settings for WordPress/WooCommerce
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.revalidate_freq = 60
opcache.fast_shutdown = 1
opcache.enable_cli = 0Add these to the account's php.ini or via the cPanel MultiPHP INI Editor.
Monitoring PHP performance โ
# Check LSAPI worker status
/usr/local/lsws/bin/lswsctrl status
# Watch real-time PHP process usage
watch -n1 "ps aux | grep lsphp | grep -v grep | wc -l"
# Check OPcache statistics (create temporarily)
echo "<?php opcache_get_status(true) | json_encode | print;" > /tmp/opcache_check.php
php /tmp/opcache_check.php | python3 -m json.tool | grep -E "hit_rate|memory_usage"
rm /tmp/opcache_check.phpA healthy OPcache hit rate is above 95%. Below that, either max_accelerated_files is too low or memory_consumption needs to be increased.

