原文网址:https://www.youyong.top/article/1158dfb6eb3f
php.ini 设置了 error_log,log_errors = On 为什么不生效?
原文网址:https://www.youyong.top/article/1158dfb6eb3f
php.ini 设置了 error_log,log_errors = On 为什么不生效?
原文网址:https://www.youyong.top/article/1158dfb6eb3f
新配置了一个项目当然要打开php日志,设置了php.ini 里面的参数:
log_errors = On
error_log = /data/logs/php/php_errors.log
然后设置 chmod 777 /data/logs/php/php_errors.log
随便在入口index.php 里 写一个错误的语法,执行,错误日志没有记录到错误日志文件。
在php文档找到这个http://php.net/manual/zh/install.fpm.configuration.php
PHP配置值通过 php_value 或者 php_flag 设置,并且会覆盖以前的值。请注意 disable_functions 或者 disable_classes 在 php.ini 之中定义的值不会被覆盖掉,但是会将新的设置附加在原有值的后面。
使用 php_admin_value 或者 php_admin_flag 定义的值,不能被 PHP 代码中的 ini_set() 覆盖。
打开环境的php-fpm.conf
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
日志确实记录到这里了 /var/log/php-fpm/www-error.log
php 记录日志 首先打开php.ini
log_errors = On
error_log = /data/logs/php/php_errors.log
且 php_errors.log 有写入权限
如果记录日志无效,那么打开php-fpm.conf 看看是否设置了php_value,一般他的权限高于php.ini
php_admin_value 权限最高,ini_set()方法也无效。
一般 ini_set() > (php_fpm.conf)php_value > php.ini
作者声明:本篇文章系本人原创,欢迎分享,但未经许可,谢绝转载。
共 0 条留言