PHP configuration file analysis - php.ini and php-cli.ini, php-fpm.conf

php.ini是PHP解析器的配置文件
php-cli.ini是PHP命令行解析器的配置文件
php-fpm.conf是PHP-FPM进程管理器的配置文件,对单一进程进行配置
  • cli command line mode and fpm mode

cli是命令行模式,直接在命令行运行。
FPM模式,fpm结合Nginx/Apache,作为其扩展对php文件进行处理。

当通过命令行(cli)执行php脚本时,使用的php-cli.ini配置
当通过FPM运行,使用的php.ini内的配置
//获取php.ini地址获取
php --ini 

//php-cli.conf配置命令行查看
php -ini

  • Note (problem where memory modification does not work)

pid:12583 Worker[12583] process terminated with ERROR: E_ERROR "Allowed memory size of 134217728 bytes exhausted (tried to allocate 995328 bytes)

1. When the service is executed and started on the command line, to modify the memory limit, you need to modify the memory_limit parameter in php-cli.ini, and modifying php.ini will not take effect.

2. When the service runs in FPM mode and combined with apache/nginx, modify the memory_limit in php.ini.

At this time, if php-fpm.conf or its imported extension file configures the memory, that is, php_admin_value[memory_limit] is configured in the extension (generally, it is commented or not configured by default, and the configuration in php.ini will be used), and the Use the memory value configured in php_admin_value[memory_limit] (phpinfo() will also display the configuration with the highest priority).

There is a priority relationship here, the parameters configured in php-fpm.conf will override the configuration in php.ini

php-fpm.conf > ini_set( ) > php.ini

php_admin_value[memory_limit]=256 > 
ini_set('memory_limit', '256M')  >
memory_limit = 256M

Auxiliary documentation about memory_limit 

Guess you like

Origin blog.csdn.net/nw_ningwang/article/details/125431085