php.ini

term

programmingweb dev

Kept in this browser · My desk

PHP's main configuration file, read when PHP starts: once, at web-server start, for a server module, and on every invocation for CGI and the command line.

PHP finds it through the SAPI's own setting (PHPIniDir in Apache, -c on the command line), the PHPRC variable, the working directory, the executable's directory and a compiled-in path, preferring php-SAPI.ini over php.ini, then reads extra .ini files from PHP_INI_SCAN_DIR. Each directive has a mode that says where else it may be changed.

The modes are INI_SYSTEM (php.ini or httpd.conf), INI_PERDIR (also .htaccess and .user.ini), INI_USER and INI_ALL (also ini_set() in a script). Under the Apache module php_admin_value fixes a setting so that neither .htaccess nor ini_set() can change it; under CGI and FastCGI PHP reads .user.ini files from the script's directory up to the document root; PHP-FPM pools take php_value and php_admin_value, and a web server can pass PHP_VALUE in the FastCGI parameters.

Two of its directives are often taken for isolation and are not, in the manual's own words: open_basedir is an extra safety net that cannot be relied upon when security is needed, and disable_functions can be circumvented and is not sufficient for shared hosting. expose_php decides whether PHP announces its version in an X-Powered-By header.

Also known as: php configuration file, .user.ini, php_admin_value, open_basedir, disable_functions, expose_php

← Back to P Back to the glossary