Serving PHP as fast as possible using Apache

Please note that UnixGuru Hosting uses LiteSpeed WebServer with LSCache & LiteMage on it’s Shared, Premium & Reseller servers. However, on CloudLinux enabled VPSs, unless the customer also chooses LiteSpeed, we will utilise mod_lsapi.

To make Apache more scalable we  are using the Event MPM, which is nginx like and just as fast as NGINX at running PHP code.

The majority of modern websites use PHP, which makes how fast you can service PHP pages crucially important.

There are many existing ways to serve PHP under Apache and they are all flawed in some way.

  • RUID2 + mod_php
    • A giant security hole that lets any user get a root account
  • MPM ITK
    • Very slow, as it kills processes after each request
  • suPHP & CGI
    • Both slow, as they start PHP on each request. They are also incompatible with opcode caching.
  • FastCGI
    • Stability issues, hard to configure due to the way it handles processes and doesn’t use opcode caching optimally.
  • PHP-FPM
    • Requires a socket/startup per customer, not that stable with Apache and creates a mess when we tried to integrate it with PHP Selector – as now PHP selector would have to restart PHP-FPM processes.

This is why we use mod_lsapi, an Apache module based on LiteSpeed

LSAPI for PHP is the fastest and most reliable we’ve found to serve PHP pages.

It is a drop in replacement for SuPHP, FCGID, RUID2 & ITK, has low memory footprint and understands PHP directives from .htaccess files.

Compatible with CloudLinux’s PHP Selector, it gives you and your customers a way to run 7 different PHP versions with 120+ PHP Extensions and customisable php.ini

Benefits of mod_lsapi

  • Speed
    • Faster than any other way to serve PHP with Apache
  • Stability
    • Doesn’t suffer from stability issues in process management like PHP-FPM
  • Opcode Caching
    • Full benefits of opcode caching are utilised
  • Event MPM compatible
    • Event MPM is very scalable
  • .htaccess honoured
    • PHP directives in .htaccess are supported
  • PHP Selector
    • Full compatibility with CloudLinux’s PHP Selector