What is the reason why the configuration file php.ini does not take effect?

The reasons why the configuration file “php.ini” does not take effect: 1. After modifying the configuration file, the “php.ini” configuration file is not reloaded, just restart the service and reload the configuration file; 2. There are multiple “php. ini” configuration file; 3. The configuration in the “php.ini” file is overwritten by the configuration in other files.

php.ini does not take effect

The operating environment of this tutorial: Windows7 system, PHP7.1 version, DELL G3 computer

1. After modifying the php.ini configuration file, the php.ini configuration file is not reloaded.

2. There are multiple php.ini configuration files

3. The configuration in php.ini is overwritten by the configuration in other files


1. After modifying the configuration, reload the php.ini file, print out phpinfo();which configuration file was read, and make sure that the configuration file you modified is correct. As shown below:


2. Search for the configuration you modified in the printout phpinfo();, pay attention to Local Value (local variable) and Master Value (main variable), Local Value will override the value of Master Value, Master Value is the value of your php.ini configuration item, and Local Value may be the value set in the code, as shown below, eg: ini_set(‘display_errors’,true);,

In addition, Baidu said that the settings of php.ini can be rewritten in the Apache configuration file, which may be in conf/httpd.conf, or in conf.d/**.conf, generally in conf.d/php.conf, But the conf.d file is not found under windows, maybe there is a conf.d file under the linux version of apache.


3. In the Linux environment, before php5.3.3, php-fpm has not been included in php, and the configuration of php is basically in php.ini. In php5.3.3 and later, in addition to the configuration in php.ini, it can also be configured in php-fpm It is configured in .conf, and php-fpm.conf has a higher priority than php.ini.

Check the php-fpm.conf configuration file, or whether the configuration in the php-fpm.d/.conf file overrides the configuration in php.ini. The configuration example of php-fpm is as follows:

php_value[session.save_handler] = redis php_value[session.save_path] = "tcp://***.***.***.***:6379?auth=***"

Posted in: PHP

Leave a Reply

Your email address will not be published. Required fields are marked *