4
It is important to note that errors that occur in running PHP script via browser are recorded without any problem in the file: /var/log/apache2/error.log
.
The problem only happens when scripts are executed via command line.
The sequence I performed is as follows::
1 - Clear Apache error log file:
root@debian:/# echo > /var/log/apache2/error.log
root@debian:/#
2 - Test whether the Apache log file has really been cleaned:
root@debian:/# cat /var/log/apache2/error.log
root@debian:/#
Ok - The file is empty.
3 - Execution of a PHP script via command line:
root@debian:/#php script.php
PHP Fatal error: Call to a member function setWhere() on null in /var/www/html/script.php on line 38
root@debian:/#
4 - Consult the Apache log file:
root@debian:/# cat /var/log/apache2/error.log
root@debian:/#
The problem: the log file remains empty.
My doubt: Why do errors in PHP scripts run via the command line not appear (or are not appearing) in the apache error log? How to log these errors in said file (/var/log/apache2/error.log
)?
Thanks for your help!
It worked perfectly: php -c /etc/php/custom.ini meuscript.php
– Allan Andrade
I’m glad it worked out. If you want to automate your PHP, remember to ensure that the crontab user or the script that calls PHP has access to the file.
– Bacco