0

Using php5.6 (legacy codebase), apache, ubuntu16.

phpinfo() says that: log_errors is on error_log = /var/log/apache2/php_errors.log

When display_errors is on there is output. But /var/log/apache2/ does not contain a php_errors.log file.

Have restarted apache (/etc/init.d/apache2 restart).

log_errors_max_len is 1024.

ls -ld /var/log/apache2
drwxr-x--- 2 root   adm    4096 Mar 30 18:47 apache2

ls -l /var/log/apache2
-rw-r----- 1 root adm        0 Mar 30 06:25 access.log
-rw-r----- 1 root adm     5967 Mar 30 01:47 access.log.1
-rw-r----- 1 root adm    11618 Mar 31 04:07 error.log
-rw-r----- 1 root adm    11742 Mar 30 06:25 error.log.1

What am I missing?

Mike
  • 23,542
  • 14
  • 76
  • 87
MikeiLL
  • 6,282
  • 5
  • 37
  • 68
  • 2
    Apache2? If so, your virtual host(s) might specify other log file locations where PHP errors/warnings/etc. are output. Check `/var/log/apache2/*-error.log` – Patrick Moore Mar 31 '17 at 04:26
  • You are correct! Is there a directive I can add to separate out the php error log? – MikeiLL Mar 31 '17 at 05:18
  • try `error_log=syslog` and if it works then it is a write permission issue – Deadooshka Mar 31 '17 at 06:04
  • In fact, `phpinfo()` should display *two* values ("Local value" and "Master value") and whenever different the first one is the one in effect. You also probably need to run PHP as Apache module in order to be able to log into `/var/log/apache`. – Álvaro González Mar 31 '17 at 18:26

1 Answers1

0

From above comments. When using Apache2, each VirtualHost can have it's own log files.

So the /etc/apache2/ directory would have a sites-available directory along these lines:

├── sites-available
│   ├── 000-default.conf
│   ├── default-ssl.conf
│   ├── default-tls.conf
│   ├── www.domain.com.conf
│   └── www.domain.com-le-ssl.conf

And the www. files might look like the following example.

To set up specific php log file, separate from Apache logs, follow this answer:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/domains/example.com/html
    ErrorLog /var/www/domains/example.com/apache.error.log
    CustomLog /var/www/domains/example.com/apache.access.log common
    php_flag log_errors on
    php_flag display_errors on
    php_value error_reporting 2147483647
    php_value error_log /var/www/domains/example.com/php.error.log
</VirtualHost>
Community
  • 1
  • 1
MikeiLL
  • 6,282
  • 5
  • 37
  • 68