【发布时间】: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