PHP-FPM: php_value vs. php_admin_value directives explained

php_admin_value and php_value are directives used in PHP-FPM (FastCGI Process Manager) configuration, often seen in context with web server setups like Apache or Nginx. They are used to set values for PHP's configuration directives e.g. in a PHP-FPM pool file or in the Apache server configuration. This is an alternative to changing PHP settings in the php.ini file. The key difference between them lies in their flexibility and context of use:

php_value

  • This directive allows you to set the value of a PHP configuration option.
  • The settings made using php_value can be overridden in .htaccess or other Apache configuration contexts if you are using Apache as a web server.
  • It is used when you want to allow the possibility of these values being overridden at a later stage or in a different context, for example, for specific directories or virtual hosts.

php_admin_value

  • Similar to php_value, this directive sets the value of a PHP configuration option.
  • However, the difference is that the settings made with php_admin_value cannot be overridden in .htaccess or in other Apache contexts.
  • It is used when you want to enforce certain settings strictly, without allowing them to be changed in the web server's runtime or in user-level scripts or directories.

Essentially, the choice between php_value and php_admin_value boils down to whether or not you want the specified PHP settings to be final and unchangeable (php_admin_value), or if you're open to them being modified in specific contexts or configurations (php_value). This is particularly important for settings that might affect security or server stability, where you might prefer to use php_admin_value to enforce strict rules.

Leave a Comment