AWS Elasticbeanstalk modify php-fpm config file

elastic-beanstalkphp-fpm

My app is running on AWS Elasticbeanstalk service with PHP 7.4/AMI Linux 2 platform.
And I want to modify php-fpm configuration, especially /etc/php-fpm.d/www.conf file, which manages by Beanstalk.

AWS Documentation https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html says I can modify Nginx config, but I can't find anything about php-fpm config changing.
I've tried to put desired config in .platform/php-fpm.d/www.conf and tried to overwrite www.conf by using ebextensions, but unsuccessfully.
Did anybody do this?

Best Answer

Create a script inside .platform/hooks/predeploy. The script should create a new config file inside /etc/php-fpm.d/.

Our script for example looks like this.

#!/usr/bin/env bash

# the script starts with z so it is getting loaded after the www.conf
cat <<EOT > /etc/php-fpm.d/z-99-custom.conf
[www]
pm.max_children = 4
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 2
pm.max_requests = 10
EOT