0

A similar question has been asked already at PHP's configuration setting 'error_log' is not working, but that's not my problem.

My phpinfo(); shows

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

I try to change location to /var/log/php-fpm/www-error.log, however the location always stays on /var/opt/remi/php74/log/php-fpm/www-error.log not matter what I am doing

File /etc/php.d/impng.ini

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

I run systemctl restart httpd / systemctl restart php74-php-fpm several times

I don't see file /var/opt/remi/php74/log/php-fpm/www-error.log configured anywhere:

$ 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/*

Note, errors are written properly to /var/opt/remi/php74/log/php-fpm/www-error.log. Manual logging with error_log("test", 3, "/var/log/php-fpm/www-error.log"); is also working.

But I don't manage to change the location of error_log. Other parameters (e.g., max_execution_time) are taken properly into account as expected.

It's a minor issue. I could create symbolic link or simply read file /var/opt/remi/php74/log/php-fpm/www-error.log. However, I wonder why I cannot change it.

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • 1
    Are you sure you are trying to modify the correct configuration file to begin with? What does phpinfo say, which config file(s) were actually read? – CBroe Sep 13 '21 at 10:38
  • phpinfo list all ini-files in `/etc/php.d/`, include my custom `/etc/php.d/impng.ini` at last one - like expected. – Wernfried Domscheit Sep 13 '21 at 10:51
  • Also note it makes a difference if you are running php-fpm via browser or running a script manually from CLI. Then the file location could be different. – Markus Zeller Sep 13 '21 at 11:19
  • Can you [add](https://stackoverflow.com/posts/69160967/edit) (incl. version information for all) operating system, web server, PHP version, default shell, runtime context (web hosting/local), and relevant configuration information? – Peter Mortensen Oct 04 '21 at 13:21
  • @PeterMortensen, see answer below, it shows my configuration. – Wernfried Domscheit Oct 04 '21 at 13:32

1 Answers1

1

In Fedora and RHEL / CentOS 8, PHP is executed via the php-fpm service.

And the log is configured in the pool configuration file.

File /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

It has to be configured in the spool file, as each pool may run under a different user, so each needs its own files.

Tips: you can see the configuration files provided by a package using:

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Remi Collet
  • 6,198
  • 1
  • 20
  • 25