Repository navigation
Conversation
Modules were enabled before the others were disabled: a2enmod refuses to enable an MPM while another one is still enabled. Disabling first also no longer skips the second command when the first one fails.
They were listed as available in the README but silently ignored (APACHE_EXTENSION_*) or rejected (APACHE_EXTENSIONS). HTTP/2 is not served with mpm_prefork (required by mod_php): they are useful with the built-in Apache of the fpm variant (mpm_event).
…R=apache) The fpm variant can run Apache (mpm_event + proxy_fcgi) in front of PHP-FPM in the same container: same Apache features as the apache variant (.htaccess, APACHE_DOCUMENT_ROOT, APACHE_EXTENSION_*) without mod_php, which forces mpm_prefork (one process embedding PHP per connection). - Disabled by default: the fpm variant keeps its behavior (PHP-FPM on port 9000) - apache2-fpm-foreground runs both processes; if one of them stops, the other one is stopped too and the container exits with an error - PHP-FPM runs with the Apache user, the Authorization header is forwarded, missing PHP files are answered by Apache (404) - PHP-FPM process manager and access log configurable with PHP_FPM_PM* and PHP_FPM_ACCESS_LOG (closes thecodingmachine#410) - php-fpm-healthcheck command (ping endpoint) for Docker healthchecks and Kubernetes probes
- README: announcement, migration notes from the apache variant, PHP-FPM settings - benchmarks/fpm-apache: k6 benchmark comparing the apache variant (mod_php) and the fpm variant with its built-in Apache under the same load (constant arrival rate), with the results
…root
When the working directory belongs to root (--tmpfs, Kubernetes emptyDir, some
CI runners), the commands are run as root: PHP-FPM refused to start
("[pool www] user has not been defined"), the user directives of www.conf being
commented out. With the built-in Apache, PHP-FPM was run with the Apache user
and could not open its error log (/proc/self/fd/2 belongs to the user of the
commands): "failed to open error_log: Permission denied".
The PHP-FPM master process now runs as root in these cases (like Apache), and
its workers run with the Apache user (docker by default): a pool configuration
setting user and group is written at startup, and removed otherwise (FPM logs a
notice when the user directive is set but the master is not root).
Fixes thecodingmachine#206
…riant How to serve HTTP with the fpm image (built-in Apache, or another web server such as nginx), the advantages over the apache variant, the constraints of PHP-FPM (number of workers and memory, web server timeouts, php_value in .htaccess) and the migration from the apache variant. The README announcement and the built-in Apache section link to this page. Closes thecodingmachine#195
…EOUT) With the built-in Apache of the fpm variant, a PHP request that does not answer within the Apache timeout (300 seconds) gets a 504 error, even with set_time_limit(0). APACHE_PROXY_TIMEOUT sets ProxyTimeout (300 by default).
Absolute links pointed to the thecodingmachine repository, even when the README is read on a fork.
mistraloz
force-pushed
the
feat/fpm-builtin-apache
branch
from
October 9, 2026 13:55
dc62c82 to
1c12a53
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements :
The fpm variant can now run Apache in front of PHP-FPM, in the same container, with
PHP_FPM_WEB_SERVER=apache. It keeps the Apache features of the apache variant (.htaccess,APACHE_DOCUMENT_ROOT,APACHE_EXTENSION_*), but PHP runs in PHP-FPM instead ofmod_php.Under the same load, the container serves 2 to 3 times more traffic with 4 times less memory (30 vs 10 pages/s on 2 CPUs, ~90 vs ~380 MiB, see
benchmarks/fpm-apache).mod_phpforcesmpm_prefork, where every connection, idle keep-alive ones included, holds a process embedding PHP; with PHP-FPM, Apache usesmpm_eventand only PHP requests reach the workers. Being an option of the fpm variant rather than a new one, it adds no tag to build, and projects using the apache variant can migrate without rewriting their.htaccessrules.Along with it:
PHP_FPM_PM*), plusPHP_FPM_ACCESS_LOGandAPACHE_PROXY_TIMEOUT; aphp-fpm-healthcheckcommand is available for Docker and Kubernetes.docs/fpm.mdpage explains how to serve HTTP with the fpm image (built-in Apache or nginx), the constraints of PHP-FPM (number of workers andmemory_limit, timeouts andset_time_limit(),php_valuein.htaccess) and how to migrate. The README announcement links to it.--tmpfs,emptyDir...): its master runs as root and its workers with the Apache user.APACHE_EXTENSION_*now works (the MPM is disabled last), andhttp2/proxy_http2are accepted.Closes #410
Closes #206
Closes #195
Test plan (required)
variant-fpm.shcovers the built-in Apache (configuration,.htaccess, headers, timeouts, healthcheck, stops and crashes) and the start with a root-owned working directory;variant-apache.shcovers the MPM switch. They pass on PHP 8.4:The benchmark can be run with
benchmarks/fpm-apache/run.sh 8.4.Checklist