php.ini 设置了 error_log 为什么不生效?

赞赏 2016-07-12

php.ini 设置了 error_log,log_errors = On 为什么不生效?


  • 背景

新配置了一个项目当然要打开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

登陆后阅读全文
阅读 4197 赞赏 0 有用 23 没用 2 收藏 10 分享

   


作者声明:本篇文章系本人原创,欢迎分享,但未经许可,谢绝转载。

0 条留言

有经验的老司机的头像

有经验的老司机

年轻人,走!我带你。

有料推荐

这世界欠我一个这样的老公!

高校学生模仿“世界名画”摆拍,可以说是戏精本精了

iPhone X 跌破发行价,苏宁200亿入股恒大 | 财经日日评

果然是高手!这次在日本,特朗普竹杠敲得不是一般狠

资深黄牛现身说法:iPhone X价格秒变不停,就像炒股一样

长一样的双胞胎也能识别?蚂蚁金服发布「眼纹识别」技术

苏联是怎么被阿富汗拖垮的?

美团或入局「分时租赁」共享汽车,王兴要大笔投入「泛出行」领域了? | 36氪独家

你或许被“一盘番茄炒蛋”刷屏了,但有人辛酸,有人质疑

iPhone X发售前夜,黄牛与苹果公司的不安

他的文章

电脑无线连接安卓手机 进入android命令行模式(完胜adb shell数据线连接方式)

iTerm2配置clone session功能

如何科学上网(翻墙)

php5.6-和php5.6 CURL 上传文件的一个坑

如何修改lumen storage path/log path

php.ini 设置了 error_log 为什么不生效?

IP查询二分法的运用

iframe 的高度自适应 iframe 内容页面的高度解决方案

手机扫一扫
分享文章