在 Debian 上排查 PHP 报错,一般可以按下面几个思路来查。
php --ini
或
php -i | grep "Loaded Configuration File"
在 php.ini 中关注:
error_log = /var/log/php/php_errors.log
display_errors = Off
log_errors = On
tail -f /var/log/php/php_errors.log
(路径可能不同,如 /var/log/apache2/error.log 或 /var/log/nginx/error.log)
tail -f /var/log/apache2/error.log
tail -f /var/log/nginx/error.log
tail -f /var/log/php-fpm.log
或
journalctl -u php-fpm
直接运行:
php your_script.php
错误信息会直接显示在终端。
临时开启错误显示:
php -d display_errors=1 -d error_reporting=E_ALL your_script.php
display_errors=Offphp -l file.php
systemctl status php-fpm
journalctl -xe
php -m
安装示例:
apt install php-mysql php-curl
在 PHP 文件顶部加:
error_reporting(E_ALL);
ini_set('display_errors', '1');
如果你能贴出:
我可以帮你更精准定位。