๐ŸŸข Network Status| First month from $2.00 โ€” fully managed | Contact Support
Skip to content
Need help? Real engineers available 24/7. Average response under 15 minutes. Open a support ticket โ†’

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 โ€‹

ModePHP process lifecycleIPC overhead
mod_phpNew process per Apache workerNone (in-process)
PHP-FPMPersistent pool, Unix socketSocket per request
LSAPIPersistent pool, shared memoryNear-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 โ€‹

bash
# 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.conf

In 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):

SettingDefaultRecommended for high traffic
Max Connections35100โ€“200
Initial Request Timeout60s60s
Retry Timeout00
Persistent ConnectionYesYes
Auto StartYesYes

Per-account PHP settings โ€‹

For cPanel servers, LSAPI respects php.ini values set through:

  1. cPanel โ†’ Software โ†’ MultiPHP INI Editor โ€” GUI for common settings
  2. .htaccess directives โ€” php_value, php_flag
  3. Custom php.ini in the document root
bash
# 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
EOF

OPcache tuning โ€‹

OPcache is critical for PHP performance โ€” it caches compiled bytecode so PHP files don't need to be parsed on every request.

ini
; 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 = 0

Add these to the account's php.ini or via the cPanel MultiPHP INI Editor.

Monitoring PHP performance โ€‹

bash
# 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.php

A healthy OPcache hit rate is above 95%. Below that, either max_accelerated_files is too low or memory_consumption needs to be increased.

Managed hosting that actually manages.