在 CentOS + LAMP(Linux + Apache + MySQL/MariaDB + PHP) 环境下,常见日志位置和查看方式如下:
/var/log/httpd/
常见文件:
access_logerror_log# 实时查看错误日志
tail -f /var/log/httpd/error_log
# 查看最近 100 行
tail -n 100 /var/log/httpd/error_log
# 搜索关键字
grep "error" /var/log/httpd/error_log
php --ini
或
php -i | grep error_log
常见路径:
/var/log/php-fpm/error.log
/var/log/php_errors.log
tail -f /var/log/php-fpm/error.log
/var/log/mysqld.log
# 或
/var/log/mariadb/mariadb.log
查看:
tail -f /var/log/mysqld.log
SHOW VARIABLES LIKE 'slow_query_log';
SHOW VARIABLES LIKE 'slow_query_log_file';
# 系统日志
tail -f /var/log/messages
# 使用 journalctl(CentOS 7+)
journalctl -u httpd
journalctl -u mariadb
journalctl -u php-fpm
# 查看 Apache 是否报错
tail -f /var/log/httpd/error_log
# 查看 PHP 错误
tail -f /var/log/php-fpm/error.log
# 查看数据库错误
tail -f /var/log/mysqld.log
# 综合查看系统日志
journalctl -xe
如果你能说明 具体是哪种问题(网站打不开 / 500错误 / 数据库连接失败等),我可以帮你精准定位该看哪个日志。