Debian LAMP处理错误可按以下步骤进行:
查看日志
/var/log/apache2/error.log/var/log/mysql/error.log/var/log/php_errors.log(需在php.ini中配置)tail -f实时查看日志,定位错误信息。常见错误处理
/etc/apache2/)、MySQL(/etc/mysql/)、PHP(/etc/php/)的配置文件语法,修复错误后重启服务。www-data)对网站目录有读写权限:sudo chown -R www-data:www-data /var/www/htmlsudo chmod -R 755 /var/www/html。sudo apt install libapache2-mod-phpsudo a2enmod 模块名。netstat -tulnp检查端口占用,修改服务端口或停止冲突服务。sudo ufw allow 'Apache Full'。高级调试
php.ini中开启log_errors和display_errors(开发环境建议开启,生产环境关闭display_errors)。set_error_handler和set_exception_handler函数实现代码级错误捕获。系统级维护
sudo apt update && sudo apt upgrade。logrotate管理日志文件,避免占用过多磁盘空间。参考来源:[1,2,3,5,6,7,8,9,10,11,12,13,14]