; 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 ; Allow worker processes to write to stderr, which is essential for container logging. decorate_workers_output = no ; 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