【问题标题】:Setting "error_log" location is not taken into account不考虑设置“error_log”位置
【发布时间】:2021-11-08 15:29:00
【问题描述】:

PHP's configuration setting 'error_log' is not working 已经提出了类似的问题,但这不是我的问题。

我的phpinfo(); 节目

Directive Local Value Master Value
error_log /var/opt/remi/php74/log/php-fpm/www-error.log /var/opt/remi/php74/log/php-fpm/www-error.log
max_execution_time 456 456

我尝试将位置更改为/var/log/php-fpm/www-error.log,但无论我在做什么,该位置始终保持在/var/opt/remi/php74/log/php-fpm/www-error.log

文件/etc/php.d/impng.ini

max_execution_time = 456
error_log = /var/log/php-fpm/www-error.log

我多次运行systemctl restart httpd / systemctl restart php74-php-fpm

我没有看到文件/var/opt/remi/php74/log/php-fpm/www-error.log 在任何地方配置:

$ grep php_admin_value /etc/httpd/conf/*
$ grep php_admin_value /etc/httpd/conf.d/*
$ grep php_admin_value /etc/httpd/conf.modules.d/*
$ grep php_admin_value /etc/php.d/*
$ grep error_log /etc/php.d/*
/etc/php.d/impng.ini:error_log = /var/log/php-fpm/www-error.log
    
$ grep ErrorLog  /etc/httpd/conf/*
/etc/httpd/conf/httpd.conf:# ErrorLog: The location of the error log file. 
/etc/httpd/conf/httpd.conf:# If you do not specify an ErrorLog directive within a <VirtualHost> 
/etc/httpd/conf/httpd.conf:ErrorLog "logs/error_log"

$ grep ErrorLog  /etc/httpd/conf.d/*
/etc/httpd/conf.d/ssl.conf:ErrorLog logs/ssl_error_log

$ grep ErrorLog  /etc/httpd/conf.modules.d/*

注意,错误已正确写入/var/opt/remi/php74/log/php-fpm/www-error.log。使用error_log("test", 3, "/var/log/php-fpm/www-error.log"); 进行手动记录也可以正常工作。

但我无法更改error_log 的位置。其他参数(例如,max_execution_time)按预期适当考虑。

这是一个小问题。我可以创建符号链接或简单地读取文件/var/opt/remi/php74/log/php-fpm/www-error.log。但是,我想知道为什么我不能改变它。

【问题讨论】:

  • 您确定要修改正确的配置文件吗? phpinfo 说什么,实际读取了哪些配置文件?
  • phpinfo 列出 /etc/php.d/ 中的所有 ini 文件,包括我的自定义 /etc/php.d/impng.ini 最后一个 - 符合预期。
  • 另请注意,如果您是通过浏览器运行 php-fpm 或从 CLI 手动运行脚本,则会有所不同。那么文件位置可能不同。
  • 你能add(包括所有版本信息)操作系统、Web 服务器、PHP 版本、默认 shell、运行时上下文(Web 托管/本地)和相关配置信息吗?
  • @PeterMortensen,请参阅下面的答案,它显示了我的配置。

标签: php apache logging configuration error-logging


【解决方案1】:

FedoraRHEL / CentOS 8 中,PHP 是通过 php-fpm 服务执行的。

并且日志是在池配置文件中配置的。

文件/etc/opt/remi/php74/php-fpm.d/www.conf

...
; 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/opt/remi/php74/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 128M

; Set the following data paths to directories owned by the FPM process user.
;
; Do not change the ownership of existing system directories, if the process
; user does not have write permission, create dedicated directories for this
; purpose.
;
; See warning about choosing the location of these directories on your system
; at http://php.net/session.save-path
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/opt/remi/php74/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/opt/remi/php74/lib/php/wsdlcache
;php_value[opcache.file_cache]  = /var/opt/remi/php74/lib/php/opcache
;php_value[opcache.preload] = /var/www/html/preload/preload.php
;php_value[opcache.preload_user] = apache

它必须在假脱机文件中配置,因为每个池可能在不同的用户下运行,因此每个池都需要自己的文件。

提示:您可以使用以下方式查看包提供的配置文件:

rpm --query --configfiles php74-php-fpm

/etc/httpd/conf.d/php74-php.conf
/etc/logrotate.d/php74-php-fpm
/etc/opt/remi/php74/php-fpm.conf
/etc/opt/remi/php74/php-fpm.d/www.conf

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-27
    • 1970-01-01
    • 1970-01-01
    • 2010-12-13
    • 2014-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多