• Resolved Barry

    (@barrypersonalctonet)


    I have been using Error Log Monitor for years, and it is one of the plugins I install for all of the sites I support.

    I have a development server running nginx, and I recently reconfigured it to allow for multiple versions of PHP. The default version was upgraded to PHP 8, and I then installed PHP 7.4 with an additional instance of php-fpm and set that to be the version that most of the sites on the server are running, until I can switch them over to test with version 8.

    In the server blocks, the error log for each site is explicitly defined, and its location has not changed from before the PHP configuration changes. Each site’s wp-config has a correct ELM configuration that points to the log file, and all of that was working prior to the PHP changes. However, ELM is now unable to find the log files or display errors, and for sites that were working correctly before, I see an error:

    The log file /var/opt/remi/php74/log/php-fpm/www-error.log does not exist or is
    inaccessible.

    and ELM displays the message that is usually shows when a site is not yet configured:

    Error Log Monitor setup

    To start logging errors you’ll need to make a few changes to the WordPress
    configuration.

    Ownership and file permissions look correct to me, but obviously something is not right somewhere. Any suggestion on where to look?

    Thanks,

    Barry

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Janis Elsts

    (@whiteshadow)

    Just to clarify, are you saying that the plugin shows the correct file name, and the file exists, but the plugin reports that the file doesn’t exist? If that’s the case, I would still think that the problem is related to file permissions. Could it be that PHP is running under a different user account now, so the file permissions that worked fine before no longer work?

    Another possibility that comes to mind is open_basedir. Is the site using open_basedir or anything else that could prevent PHP from accessing files outside specific directories?

    Thread Starter Barry

    (@barrypersonalctonet)

    Yes, the plugin shows the correct name for the overall php-fpm log for 7.4, which exists, but is apparently not accessible. The second php-fpm process had defaulted to running as the apache user, but I changed that to nginx which is what the first php-fpm process runs as. I also changed the file permissions of the global log to 777 and restarted services, but that did not change anything.

    I just checked, and interestingly I saw that on a site on the server that I have configured to run PHP 8, which is the default PHP version, ELM is working fine. So something about the configuration for the secondary version of PHP is the issue.

    Open_basedir is not enabled here. SELinux is configured but is currently set to not enforce policies, and is not showing any alerts anyway.

    Barry

    Plugin Author Janis Elsts

    (@whiteshadow)

    Try changing the permission on the directory that contains the log file. I think this usually shouldn’t be necessary, but it could be a useful test.

    I’ve seen some comments that SELinux can cause problems like this, but I’m not sufficiently familiar with it to say if that applies here.

    Thread Starter Barry

    (@barrypersonalctonet)

    Ok thanks. The immediate issue was in fact the directory ownership, which was set to apache instead of nginx. Once I changed it, ELM was able to access the global php-fpm log.

    Which is fine, but now ELM in every site on the server is showing the errors from the global php-fpm error log, instead of the site specific error logs that are configured for each in the nginx server blocks, and which are pointed to in the ELM settings I put in the wp-config for each site, and which reside in a different location than the global log. On the same server, the sites that are still using the original instance of php-fpm are correctly referencing the site specific logs that are defined.

    So how can I get ELM to respect the settings for the log files, and reference the site specific log files for the sites using php-fpm for the other version?

    Thanks,

    Barry

    Plugin Author Janis Elsts

    (@whiteshadow)

    The wp-config.php code that the plugin suggests is just a quick way to enable error logging in PHP. It’s not specific to this plugin. Technically, you may not even need it if you have already enabled logging through other means like the server configuration.

    ELM gets the actual log file name from the active PHP configuration, i.e. the error_log option. If ELM shows the wrong file name, that almost certainly means that PHP is also using the wrong log file.

    It’s possible that the code in wp-config.php isn’t working or that it is overridden by something else. For example, it could be that some other part of the PHP configuration prevents PHP scripts from changing the configuration with ini_set(), or that the error_log option specifically can’t be changed.

    Are any PHP errors (or warnings, etc) actually getting logged to the site-specific logs?

    Unfortunately, I’m not familiar with nginx, so I can’t say if or how the way logging in configured in nginx could affect things.

    Thread Starter Barry

    (@barrypersonalctonet)

    Ok thanks. I will compare the php-fpm configurations for the different instances and see if I can pin down what is going on.

    Thread Starter Barry

    (@barrypersonalctonet)

    Ok, the newly installed second version of php-fpm had the default setting in https://www.conf that pointed to a log file:

    php_admin_value[error_log] = /var/opt/remi/php74/log/php-fpm/www-error.log

    I commented that out and added:

    php_admin_value[display_errors] = ‘stderr’

    and the individual log file configurations went back to working again.

    Sorry for any inconvenience, and thanks for your help.

    Barry

    Plugin Author Janis Elsts

    (@whiteshadow)

    All right, I’ll mark this as resolved.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Set up for multiple PHP versions; now can’t find log’ is closed to new replies.