3

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?

aranel
  • 111
  • 2
  • 7

1 Answers1

6

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
  • Thanks, this works, but this also can be done with ebextensions. Looks like there is no way to overwrite beanstalk php-fpm config. – aranel May 07 '21 at 15:23
  • Yea ebextensions is also correct. `.platform` is just the directory for the new aws linux platform -> https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html – Michael Malura May 10 '21 at 18:07
  • 1
    This was helpful for customization to handle different deployment environments by using an if else case with the environment variables – otaku Jun 15 '21 at 15:15
  • True. We created a simple script that merges all hooks for the target system. We copy files from deployment_hooks/general and deployment_hooks/production to .platform/hooks/predeploy – Michael Malura Jun 15 '21 at 15:20