Topic: PHP 7.3, 2 identical servers, logging behaviour completely different.

Hi

I am not sure whether this is a REMI problem or other.

I have two servers, one is a public server, one is my development server.

Both have the same OS version (CentOS7.7), both use the SAME setup for php (remi), both have the SAME php.ini, both have the same packages (plus versions!) installed - except a few non apache/php related packages (development machine) they are nearly identical machines.

Both used to log all php errors and error_log() to the php.ini defined error_log file: "/var/log/php". I have just updated to php 7.3, everything is working fine EXCEPT the logging. Now the development machine logs to php log while the public machine logs to ANY of the apache error logs.

I cannot work out why this is the case and I need some help with this, please.

I have asked the same on Stackoverflow "https://stackoverflow.com/questions/589 … r-logs-apa", it has more information including LOG file output.

So what am I doing wrong?
Help this is frustrating as error messages are all over the place.

thanks

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Prod server serves https, which seems different

php.ini is the worst place to change configuration (see PHP documentation)

Check SSL vhost configuration which may redefine log options (which is the proper place to do it)

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Remi wrote:

Prod server serves https, which seems different

I specifically did not mention a machine/site/domain.
You are making an assumption, they are both serving HTTPS.
Also if you come from an external address only for ONE domain on the development server you are not redirected, for all others you end up on the main site.
This was done to prevent robots from cataloging dev sites.

Also the config files are the same for both development and production servers (except of course the domain name).

Remi wrote:

php.ini is the worst place to change configuration (see PHP documentation)

I have been using PHP since 2003, I have never ever had a problem setting

error_log=/var/log/php

The problem ONLY started after upgrading to 7.3.
Before that for any site on any of my machines any php error was happily logged to the error_log file specified in php.ini

Also where does it say NOT to use php.ini?


Remi wrote:

Check SSL vhost configuration which may redefine log options (which is the proper place to do it)

Again, as I said before, it was fine until I changed to php7.3
For all versions from php4 to php7.1 it was logged to /var/log/php.
I also did not make any changes to any of the Apache config files after/before upgrading to PHP7.3

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Sorry but I cannot reproduced, tested with various versions

Using stock configuration + /etc/php.d/override.ini

date.timezone = Europe/Paris
error_reporting = E_ALL
error_log = "/var/log/php/error.log"

Running from root account

# cd /var/log
# mkdir php
# chown apache php

In /var/log/php/error.log

[20-Nov-2019 09:58:57 Europe/Paris] === Version:7.2.24  LOG:/var/log/php/error.log ===
[20-Nov-2019 09:58:57 Europe/Paris] PHP Notice:  Undefined variable: NotDefined in /var/www/html/index.php on line 3
[20-Nov-2019 09:58:57 Europe/Paris] 
[20-Nov-2019 09:59:32 Europe/Paris] === Version:7.3.12  LOG:/var/log/php/error.log ===
[20-Nov-2019 09:59:32 Europe/Paris] PHP Notice:  Undefined variable: NotDefined in /var/www/html/index.php on line 3
[20-Nov-2019 09:59:32 Europe/Paris] 
[20-Nov-2019 10:00:11 Europe/Paris] === Version:7.4.0RC6  LOG:/var/log/php/error.log ===
[20-Nov-2019 10:00:11 Europe/Paris] PHP Notice:  Undefined variable: NotDefined in /var/www/html/index.php on line 3
[20-Nov-2019 10:00:11 Europe/Paris] 
Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Notice: by default /var/log/ is owned by root and apache CANNOT write there


> I have been using PHP since 2003, I have never ever had a problem setting

Still a bad practice

php.ini is global settings, applied to all users,
and obviously such setting have to be defined per user, so per sapi, so in vhost configuration

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Remi wrote:

Notice: by default /var/log/ is owned by root and apache CANNOT write there

Sigh!!
Wouldn't you think I know this especially I have actually specified that there was NO PROBLEM before switching to 7.3 since version 3.x of PHP?
I also showed a 'ls -al' listing of the permissions of the /var/log/php file and you can see the permissions are correct!
Logrotate does a bloody good job keeping those permissions, too!!

Why do people always assume the person with a problem is a fool or has not clue what they are doing?
You basically did exactly this with your "Notice: by default ..."


Remi wrote:

Still a bad practice
php.ini is global settings, applied to all users,
and obviously such setting have to be defined per user, so per sapi, so in vhost configuration

It might be a bad practice for certain cases, why the need to globalize especially everyone has different requirements?
We do not use multiple users for multiple sites for multiple vhosts.
This is totally OK for us.
Why would we want to set some configuration setting and have to update all vhosts when we can do this at one single location?

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Again, I cannot reproduce.

> I also showed a 'ls -al' listing of the permissions of the /var/log/php file

Please: ls  -ld /var/log  /var/log/php

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

> Why do people always assume the person with a problem is a fool or has not clue what they are doing?

You should understand that trying to help people is hard.
Lot of questions from lot of people with very different sysadmin skills
And most of the time, from newbie without any basic knowledge

And nearly impossible to guess who ask reading a first message,

BTW, I spent lot of time trying to reproduce your issue

- fresh CentOS 7.7 VM
- setup your configuration
- making it work (reason from my notice, it can't work with default perm)
- update to 7.3, still work
- update to 7.4, still work
- read PHP sources code to find the logging function

And the only case I can see which explain the behavior you encounter, is "permission" denied and fallback to default SAPI logging.

And I said, you have to check by tracing a debug process:

    strace httpd -X

and search for /var/log message there

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Remi wrote:

Again, I cannot reproduce.

> I also showed a 'ls -al' listing of the permissions of the /var/log/php file

Please: ls  -ld /var/log  /var/log/php

Sorry for the late reply, I got a call yesterday as a couple of teams had injured goalies so I jumped in (it was meant to be my day off)

The perms were always ok, never had any problems before, to help with debugging:

drwxrwx--x 20 root   apache  4096 Nov 25 10:40 /var/log
drwxrwx--x 20 root   apache  4096 Nov 25 10:40 /var/log/httpd
-rw-rw----  1 apache apache 39333 Nov 25 10:40 /var/log/php

I normally do not have /var/log set to 771 as logrotate spits the dummy big time.
But on the other hand logrotate makes sure logfiles are created with the correct permissions when they are rotated.

I am going to do some more research/debugging on this....

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Remi wrote:

> Why do people always assume the person with a problem is a fool or has not clue what they are doing?

You should understand that trying to help people is hard.
Lot of questions from lot of people with very different sysadmin skills
And most of the time, from newbie without any basic knowledge

Point taken.
I can also be blunt.

Thanks for trying, and I really mean that!

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

A few days ago I found some "change log" for PHP7.3.X to higher PHP7.3.Y

I cannot 100% remember what one of the coders wrote, but it was something like "made changes to error_log ... harcoded ..."

I have been trying to find that again, then check the source what has been done.

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

IIRC, the only change in log in 7.3 are related to FPM, and, according to problem description, you are using the old deprecated mod_php

And FPM uses by default a dedicated log file, configured in the pool definition.

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

13 (edited by jobst 2019-11-25 22:17:21)

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Remi wrote:

IIRC, the only change in log in 7.3 are related to FPM, and, according to problem description, you are using the old deprecated mod_php

And FPM uses by default a dedicated log file, configured in the pool definition.

I do NOT use the old mod_php, I did use it for webtatic71 (as it is the default), but not remi73,
here is the cat of the lines of yum.log JUST after the install of remi73:

Nov 13 15:57:49 Erased: 1:php71w-pear-1.10.4-1.w7.noarch
Nov 13 15:57:50 Erased: php71w-process-7.1.33-1.w7.x86_64
Nov 13 15:57:51 Erased: php71w-xml-7.1.33-1.w7.x86_64
Nov 13 15:57:51 Erased: php71w-snmp-7.1.33-1.w7.x86_64
Nov 13 15:57:51 Erased: php71w-bcmath-7.1.33-1.w7.x86_64
Nov 13 15:57:52 Erased: php71w-devel-7.1.33-1.w7.x86_64
Nov 13 15:57:53 Erased: php71w-cli-7.1.33-1.w7.x86_64
Nov 13 15:57:53 Erased: php71w-mbstring-7.1.33-1.w7.x86_64
Nov 13 15:57:54 Erased: php71w-gd-7.1.33-1.w7.x86_64
Nov 13 15:57:54 Erased: php71w-imap-7.1.33-1.w7.x86_64
Nov 13 15:57:55 Erased: php71w-xmlrpc-7.1.33-1.w7.x86_64
Nov 13 15:57:55 Erased: php71w-mysqlnd-7.1.33-1.w7.x86_64
Nov 13 15:57:56 Erased: php71w-pdo-7.1.33-1.w7.x86_64
Nov 13 15:57:57 Erased: php71w-ldap-7.1.33-1.w7.x86_64
Nov 13 15:57:57 Erased: php71w-soap-7.1.33-1.w7.x86_64
Nov 13 15:57:58 Erased: php71w-mcrypt-7.1.33-1.w7.x86_64
Nov 13 15:57:58 Erased: php71w-dba-7.1.33-1.w7.x86_64
Nov 13 15:57:59 Erased: php71w-common-7.1.33-1.w7.x86_64
Nov 13 15:58:00 Erased: mod_php71w-7.1.33-1.w7.x86_64
Nov 13 15:58:58 Installed: libargon2-20161029-3.el7.x86_64
Nov 13 15:58:58 Installed: libwebp7-1.0.2-1.el7.remi.x86_64
Nov 13 15:58:59 Installed: gd-last-2.2.5-10.el7.remi.x86_64
Nov 13 15:59:00 Installed: libargon2-devel-20161029-3.el7.x86_64
Nov 13 15:59:01 Installed: php-common-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:02 Installed: php-json-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:03 Installed: php-cli-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:03 Installed: php-xml-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:04 Installed: php-process-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:05 Installed: php-pdo-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:05 Installed: php-fedora-autoloader-1.0.0-1.el7.remi.noarch
Nov 13 15:59:06 Installed: lmdb-libs-0.9.22-2.el7.x86_64
Nov 13 15:59:07 Installed: libedit-devel-3.0-12.20121213cvs.el7.x86_64
Nov 13 15:59:07 Installed: php-devel-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:08 Installed: fftw-libs-double-3.3.3-8.el7.x86_64
Nov 13 15:59:09 Installed: oniguruma5-6.9.3-3.el7.remi.x86_64
Nov 13 15:59:09 Installed: libraqm-0.7.0-1.el7.x86_64
Nov 13 15:59:10 Installed: LibRaw-0.19.2-1.el7.x86_64
Nov 13 15:59:11 Installed: ImageMagick6-libs-6.9.10.71-1.el7.remi.x86_64
Nov 13 15:59:12 Installed: php-pecl-imagick-3.4.4-2.el7.remi.7.3.x86_64
Nov 13 15:59:13 Installed: php-pecl-imagick-devel-3.4.4-2.el7.remi.7.3.x86_64
Nov 13 15:59:13 Installed: php-mbstring-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:14 Installed: php-dba-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:16 Installed: 1:php-pear-1.10.9-4.el7.remi.noarch
Nov 13 15:59:17 Installed: php-mysqlnd-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:17 Installed: php-xmlrpc-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:18 Installed: php-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:19 Installed: php-pecl-mcrypt-1.0.3-1.el7.remi.7.3.x86_64
Nov 13 15:59:20 Installed: php-gd-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:20 Installed: php-soap-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:21 Installed: php-bcmath-7.3.11-1.el7.remi.x86_64
Nov 13 15:59:22 Installed: php-imap-7.3.11-1.el7.remi.x86_64
Nov 13 16:02:21 Installed: environment-modules-3.2.10-10.el7.x86_64
Nov 13 16:02:24 Installed: php73-runtime-2.0-1.el7.remi.x86_64
Nov 13 16:02:25 Installed: php73-php-json-7.3.11-1.el7.remi.x86_64
Nov 13 16:02:26 Installed: php73-php-common-7.3.11-1.el7.remi.x86_64
Nov 13 16:02:26 Installed: php73-php-pecl-ssh2-1.2-1.el7.remi.x86_64

See, no mod_php.

Additionally as I added this afterwards:

Nov 13 16:25:09 Installed: php-fpm-7.3.12-1.el7.remi.x86_64

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

> Nov 13 15:59:18 Installed: php-7.3.11-1.el7.remi.x86_64

This is mod_php

And if it logs in Apache log, this mean this is mod_php.


FPM needs some configuration
https://developers.redhat.com/blog/2017 … tion-tips/

Desktop: Fedora 29 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 30 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: PHP 7.3, 2 identical servers, logging behaviour completely different.

Remi wrote:

> Nov 13 15:59:18 Installed: php-7.3.11-1.el7.remi.x86_64

This is mod_php

And if it logs in Apache log, this mean this is mod_php.

Ok!