Choosing the right PHP handler can feel like picking the engine for a car: it determines how smoothly everything runs under the hood. In this post, we’ll help you compare PHP handler options—PHP-FPM vs suPHP, mod_lsapi, and mod_php—by sharing a bit of history, real-world pros and cons, and friendly advice for each.
What Is a PHP Handler?
A PHP handler is simply the bridge between your web server (Apache, LiteSpeed, Nginx, etc.) and the PHP engine. Think of it as the conductor in an orchestra, coordinating when PHP scripts start, how they’re run, and under which user. The choice you make affects:
- Performance: page load speeds, CPU and memory usage
- Security: whether your code runs in isolation
- Scalability: how well it handles sudden traffic spikes
Now, let’s dive into each handler.
1. mod_php (DSO)
A Trip Down Memory Lane: Since PHP’s early days in 1996, mod_php has been the go-to for Apache servers. It embeds PHP directly into Apache, so every request is handled by the same process. No extra setup was needed, which made it a hit for simple sites.
Why You Might Love mod_php: If you value simplicity, mod_php is hard to beat. It just works—no separate daemons, no fuss. It’s fully compatible with Apache modules and honors your .htaccess rules, too.
The Catch: Because every Apache child process carries PHP, you’ll see higher memory use—even on pages that don’t need PHP. And since scripts run as the web server user (like apache or www-data
), you miss out on per-user isolation. That makes mod_php less ideal for shared, multi-user hosting environments. That said, mod_ruid2 does attempt to solve that problem but has it’s own problems.
2. suPHP
A Security-First Approach: Arriving around 2006, suPHP was built to tighten security. It executes PHP scripts under the file owner’s permissions, preventing one user from stepping on another’s toes.
Why You Might Choose suPHP: If you’re running shared hosting or just want strict file permission checks, suPHP shines. It ensures each script only has access to its own files, reducing the risk of cross-account hacks.
What to Watch For: Every incoming request forks a fresh process, so you’ll feel the hit in CPU load and latency. Under heavy traffic, performance can slip, and your server might struggle to keep up. If you’re aiming for speed, prepare to compromise.
3. PHP-FPM (FastCGI Process Manager)
Modern Performance Master: Introduced into PHP core with version 5.3 (2011), PHP-FPM brought an advanced FastCGI manager that supports adaptive process spawning, graceful stops, and more.
Why PHP-FPM Rocks: Its persistent worker pools mean scripts start faster, even under traffic spikes. Plus, you can run separate pools under different users, giving you the isolation of suPHP with the speed of a dedicated daemon. Tweak settings like pm.max_children
and pm.start_servers
to perfectly match your workload.
Points to Consider: All that flexibility comes with extra knobs to turn. Getting your pool settings just right takes a little trial and error. You’ll also need a bit more memory for the FPM processes themselves.
4. mod_lsapi (LiteSpeed SAPI)
LiteSpeed’s Speed Demon: Debuting in the early 2010s alongside the LiteSpeed Web Server, mod_lsapi offers an API that’s leaner and faster than standard FastCGI.
Why LiteSpeed Users Love It: Benchmarks often show mod_lsapi outpacing both PHP-FPM and traditional CGI, thanks to built-in opcode caching and streamlined I/O. It also supports per-user isolation, mirroring PHP-FPM’s security model.
Keep in Mind: It’s tied to LiteSpeed’s ecosystem, and while some control panels bundle it for free, you might hit licensing fees elsewhere. The community and documentation aren’t as extensive as PHP-FPM’s, either.
PHP-FPM vs suPHP: A Friendly Comparison
When you compare php handler choices side-by-side, PHP-FPM and suPHP often top the list for shared hosting. Here’s a quick look at how they stack up:
- Performance: PHP-FPM’s long-running pools breeze through requests, while suPHP’s process-per-request approach can lead to higher latency and CPU load under pressure.
- Memory Use: PHP-FPM shares worker pools, keeping memory lean. suPHP spawns new processes for every hit, so memory use climbs fast.
- Security: Both give you per-user execution. suPHP enforces it by default, and PHP-FPM mimics it with separate pools per account.
- Scalability: PHP-FPM scales effortlessly, handling hundreds of simultaneous connections. suPHP can buckle under heavy traffic.
In a nutshell, php-fpm vs suphp boils down to speed versus simplicity. If you need raw performance and can handle some setup, PHP-FPM wins. If your priority is rock-solid security with minimal tuning, suPHP still has its place.
Picking the Perfect PHP Handler
- Traffic Profile: Light traffic? suPHP’s security-first model works fine. Heavy traffic? PHP-FPM or mod_lsapi are your best bets.
- Security Needs: For strict isolation on shared servers, suPHP and PHP-FPM pools both deliver.
- Resources: Tight memory? Avoid mod_php. CPU-bound sites? Give mod_lsapi or finely tuned PHP-FPM a try.
- Ecosystem: If you’re on LiteSpeed or using a specific control panel, mod_lsapi might be a seamless swap. Otherwise, the community-tested PHP-FPM is hard to beat.
Feeling overwhelmed? Start with PHP-FPM for its sweet spot of speed and security, then adjust as you learn your users’ patterns.
Choosing between php-fpm vs suphp, mod_lsapi, and mod_php doesn’t have to be a leap of faith. With the pros and cons laid out, you’re ready to match your server’s needs to the handler that will keep your sites running smoothly.
TLDR: Use php-fpm.