Files
wordpress-docker/php-fpm/7.4/www.conf
Elijah Duffy 415cd4baf8
Some checks failed
php-fpm-build / build (7.4) (push) Failing after 40s
php-fpm: improve dockerfile, switch to per-lane www.conf
Shared www.conf isn't viable due to differing supported options between
PHP-FPM versions. Additionally, the Dockerfile multi-stage build wasn't
useful as it copied build artifacts. Switched to single-stage with build
artifact pruning.
2025-12-08 02:25:54 -08:00

55 lines
2.1 KiB
Plaintext

; PHP-FPM pool configuration for PHP 7.4, optimized for WordPress in a container.
[www]
; Listen on a TCP socket. This is standard for containerized setups
; where Nginx and PHP-FPM are in separate containers.
listen = 0.0.0.0:9000
; Run as the non-root 'app' user for security.
user = app
group = app
; Use the 'dynamic' process manager to scale child processes based on demand.
; This is memory-efficient for sites with variable traffic.
pm = dynamic
; The maximum number of child processes to be created.
; This is the most important setting. The value depends on available RAM.
; A typical WordPress process can use 30-60MB RAM. 10 children = ~300-600MB.
; Adjust this based on your container's memory limit.
pm.max_children = 10
; The number of child processes created on startup.
pm.start_servers = 2
; The minimum number of idle processes. If less than this, new ones will be created.
pm.min_spare_servers = 1
; The maximum number of idle processes. If more than this, some will be killed.
pm.max_spare_servers = 3
; The number of requests each child process should execute before respawning.
; This is a crucial feature to prevent memory leaks from third-party code or plugins.
pm.max_requests = 500
; The timeout for serving a single request after which the worker process will be killed.
; Helps prevent long-running scripts from tying up resources.
request_terminate_timeout = 300s
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the slowlog. Useful for debugging performance issues.
request_slowlog_timeout = 5s
slowlog = /var/log/php/www-slow.log
; Redirect worker stdout and stderr to the main error log.
; This ensures that any `echo` or `var_dump` calls from workers are captured in the container logs.
catch_workers_output = yes
; We are logging errors to stderr in zz-hardening.ini, so we can disable the FPM access log
; to avoid redundant logging and improve performance. Nginx should handle access logging.
; access.log = /var/log/php/www-access.log
; Ensure that PHP-FPM does not clear environment variables.
; This is important for passing variables from the container runtime (e.g., Docker Compose).
clear_env = no