Pros and Cons of mod_php vs. suexec+fcgid vs. php-fpm and Apache MPM

New thread for a discussion on the pros and cons of using mod_php vs. suexec+fcgid vs. php-fpm

Discussion began here:

From this page, php-fpm seems like a popularly used setup:

The classic solution to running unsafe extensions while serving large numbers (>100) of concurrent connections is to run PHP on fastCGI (mod_fcgid, a native apache module) and proxy dynamic requests to that from an apache instance that runs the Worker MPM.

This would enable you to scale from a few hundred up to >1000 concurrent connections with a modest amount of memory (4~8GB) when serving a mix of static and dynamic content.

Of course, you should also investigate front-end caching solutions as part of your overall deployment (memcached, varnish).

Alternatively, upgrade to apache 2.4 and its native event MPM, which handles concurrency in a much improved fashion (threads are fired off upon connection, not waiting to be polled.)

(Good overview)

Which setup gives the most security, between virtual servers, and virtual server vs. system ?

Most efficient use of memory, for apache and PHP?

Most efficient use of cached, pre-compiled PHP opcodes shared between virtual servers running same or similar PHP apps ?

Best ability to handle high loads efficiently ?

In the thread:
It is said: “Unfortunately, PHP-FPM isn’t one of the supported PHP Execution Modes.”

Does this mean we can’t use Virtualmin with Apache + PHP-FPM at all?

Currently it seems you can add a custom user script to enable/maintain Apache + PHP-FPM with Virtualmin, but it’s officially unsupported. User janeksikora has created a script to do this with nginx + PHP-FPM…

“I’ve managed to do php-fpm&nginx with a 100 line script that is executing after creating/destroying vservers (it creates php-fpm pool for each host) and modyfing source of virtualmin-nginx module (so it uses sockets – easier [sockets are like $user.socket] and faster [than TCP]). Wasn’t so hard…”