How to solve the problem that linux php.ini does not take effect

01-13-2023

This article mainly explains how to solve the problem that linux php.ini does not take effect. Interested friends may wish to take a look. The method described in this article is simple, quick and practical. Let the editor take you to learn how to solve the problem of linux php.ini not working!


Solutions for linux php.ini not working: 1. Reload php.ini configuration file; 2. Search for the configuration to be modified in the printed phpinfo(); 3. Check the php-fpm.conf configuration file to check whether the configuration in php.ini is covered.

What should I do if the linux php.ini does not take effect?

Troubleshooting the problem that php.ini does not take effect in linux environment

There are several reasons why php.ini does not take effect after modification:

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

Troubleshooting:

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


2. Search for your modified configuration in the printed phpinfo();, pay attention to Local Value (local variable) and Master Value (main variable), Local Value will overwrite 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 in the figure 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 was not found under windows, there may be a conf.d file under the linux version of apache.

QQ截图20230115102816.jpg

3. In the linux environment, php-fpm has not been included in php before php5.3.3, and the configuration of php is basically in php.ini, php5.3.3 and later, In addition to configuring in php.ini, you can also configureConfigured in php-fpm.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=***".


Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us