Search code examples
phpapache-config

custom php.ini / php_value : which takes precedence?


We could override the default php.ini settings using the

PHPINIDir /var/www/web1

directive in <VirtualHost> decription.

But I have seen php_value statements which is applied to all the sites in the httpd.conf files. For example :

php_value upload_max_filesize somevalue

Will the general settings like above override the custom php.ini settings?

Pardon me that I don't have an environment to test this out at present.


Solution

  • PHP configuration precedence order is as follows:

    1. The php.ini
    2. The conf.d directory. On some distros, there is a modularized conf.d directory. values specified in there override php.ini
    3. The directive PHPINIDir /var/www/web1 replaces 1 and 2 with your custom php.ini
    4. Apache virtual host configuration. e.g. "php_value error_reporting " overrides any php.ini
    5. .htaccess files placed inside your webspace override the above configuration
    6. Source code values specified in the source code override all other configuration

    Some (security critical) options can only be set in higher level config files