Configuring PHP.INI settings in a PHP-FPM pool
I consume PHP via Docker primarily, and to keep it manageable, I generally use a PHP-FPM container, with a web server sitting in front of it. I learned something new about PHP configuration recently that (a) made my day, and (b) kept me humble, as I should have known this all along.
What was it? quite simply, the php_admin_value
struct can be used to configure php.ini
settings for the pool. This is a great alternative to also adding PHP configuration settings via php.ini
(or an include file for php.ini
), as it allows you to keep the settings specific to that pool. That way, if you must have multiple pools (e.g., to serve multiple applications from the same machine and/or same PHP version), you can still have separate configuration for each.
How does it work? In your pool configuration, add values to that struct:
php_admin_value[memory_limit] = 32M
php_admin_flag[error_reporting] = E_ALL & ~E_NOTICE & ~E_DEPRECATED
php_admin_flat[track_errors] = Off
; etc
With ZendPHP, we just launched some Ansible tooling, which operates on the assumption that you are deploying PHP-FPM — and as part of its operation, it creates a template for the FPM pool configuration, but not for the PHP SAPI. And this is fine! Because you can use the php_admin_value
settings to configure the pool for the application you're deploying!
Looking forward to simplifying a few of my deployments with this!