So many paths, there are in today’s world for setting up server for WordPress. Here I try to provide a quick summary for understanding the different options available with regard to PHP and web servers.
There are two options for running PHP on web servers: PHP’s CGI SAPI or running it as a module for the web server.
Running PHP as CGI means that the server calls the PHP executable every time a request is made, requiring a lot of overhead. However FastCGI runs as a server and allows resources to be reused. This option is available for both Apache and Nginx.
As a module, PHP sits inside your web server. This is a lot faster as there is less overhead for each request.4 This option is only available for Apache.
mod_php is an Apache module which allows Apache to interpret PHP files. The PHP interpreter is kind of “embedded” inside the Apache process: there is no external PHP process meaning Apache and PHP can communicate better4.
Common Gateway Interface (CGI) is an interface specification that enables web servers to execute an external program (like PHP), typically to process user requests3
A binary protocol for interfacing interactive programs with a web server. A variation on the earlier Common Gateway Interface (CGI)1.
PHP FastCGI Processing Manager (FPM) is an alternative PHP FastCGI implementation with additional features for heavy-loaded sites2. PHP FPM runs as a standalone server and Apache connects to it using FastCGI module like mod_fcgid, mod_fastcgi, mod_proxy_fcgi. Performance is comparable to mod_php
MPM or Multi Mrocessing Modules are different ways the Apache server handles HTTP requests7.
Prefork is compatible with everything (thread safe). It uses multiple child processes and each process serves one request at a time.
It is not very scalable as concurrent requests are made to wait until a server process is free. Uses a lot of RAM for scaling up.
Threading is used. Child processes spin of child threads. Uses less RAM as threads are used. Better for concurrency. Threads are attached to connections, not requests — a keep alive connection will keep hold of a connection until it is closed.
Available as of Apache 2.4, mpm_event is similar to mpm_worker but uses a dedicated thread to deal with keep-alive connections.