首页 > 解决方案 > 不考虑设置“error_log”位置

问题描述

在PHP 的配置设置 'error_log' is not working中已经提出了类似的问题,但这不是我的问题。

我的phpinfo();节目

指示 当地价值 主值
错误日志 /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。但是,我想知道为什么我不能改变它。

标签: phpapacheloggingconfigurationerror-logging

解决方案


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


推荐阅读