2

I upgraded my Debian7 to Debian10 yesterday, and changed from prefork to mpm_event with php-fpm (php 7.4)

The error messages and error_log output, is shown in my /apache/error.log file as: I've replaced filenames, ip and port.

[Tue May 19 11:26:38.506805 2020] [proxy_fcgi:error] [pid 28334:tid 139811391133440] [client (ip):(port)] AH01071: Got error 'PHP message: PHP Notice: Undefined variable: SQL_ERROR in (file) on line 198PHP message: PHP Notice: Undefined variable: SQL_ERROR in (file) on line 200PHP message: PHP Notice: Undefined variable: SQL_ERROR_MSG in (file) on line 201PHP message: PHP Notice: Undefined variable: SQL_command in (file) on line 202'

And all errors are buffered, and output on the same line (quite difficult to debug).

php-fpm uses www-data user

error.log has 640 permissions with www-data:www-data

php-fpm/pool.d/www.conf got the error.log = /var/log/apache2/error.log

Do you have any suggestions, as to why i'm not getting the error logs directly in the error.log file?

Edit: All PHP configs is from a clean install.

Saku
  • 47
  • 6

2 Answers2

1

I have the same system as you, Debian 10, php-fpm 7.3 (instead of 7.4), apache2 and had the same issue with a messy output.

I solved it with a small script, manually adding the new line character \n and also a tab \t for pretty printing

#!/bin/sh
tail -f "/var/log/apache2/$1" | sed 's/PHP\s/\n\tPHP\s/g'

Now I see each message on a new line, with a simple indentation as well. You can give the script any name, I choosed greplog, placed on system path with enough permissions, and pass the log filename as parameter

Daniel Faure
  • 391
  • 6
  • 14
  • 1
    I actually ended up setting the apache log, as the php-fpm error output log. I still get the "ugly" oneliner, but all the php-fpm errors, are neatly on each line. So basically i just ignore the last one-liner. – Saku Mar 26 '21 at 13:10
  • 1
    My custom filter: `| sed -e "s/\\\\n/\\n/g" -e "s/PHP message: /\\n/g"` – Francisco R Jun 22 '22 at 15:19
-1

When upgrading from Debian 7 to Debian 10 your version of PHP was probably upgraded from 5.4 to 7.4.

PHP 7 has many breaking changes so I'm guessing that your code is using some of the features that were removed / hits syntatical changes introduced.

See here for the debian php version matrix: https://wiki.debian.org/PHP

And here for PHP breaking changes: https://www.php.net/manual/en/migration70.incompatible.php

nover
  • 2,259
  • 1
  • 27
  • 27
  • Hi nover, thanks for your reply. I installed PHP and all configs from scratch, so there shouldn't be any 5.6-stuff left. I forgot to mention that :) – Saku May 19 '20 at 18:22
  • Exactly my point - you moved from php 5.6 to 7.x? Did you ensure to check all your php scripts for 7.x compatibility?In the migration guide there is a section called `Calls from incompatible context removed` which shows some "undefined variable" outputs. Could be your problem :) – nover May 20 '20 at 09:01
  • Hello :) I've tried with an "empty" file. just echoing "test" from the error_log, and the result is the same. It's being directed through the "syslogger" (i think?), instead of going directly to the error log file – Saku May 23 '20 at 16:52