在 CentOS 系统中,Apache 日志文件通常位于 /var/log/httpd/ 目录下。要查看 Apache 日志,你可以使用以下命令:
sudo tail -f /var/log/httpd/access_log
这个命令会实时显示访问日志的内容。如果你想查看某个时间段内的日志,可以使用 grep 命令进行筛选,例如查看 2021 年 10 月的日志:
sudo grep '2021-10' /var/log/httpd/access_log
sudo tail -f /var/log/httpd/error_log
同样,这个命令会实时显示错误日志的内容。如果你想查看某个时间段内的错误日志,可以使用 grep 命令进行筛选,例如查看 2021 年 10 月的错误日志:
sudo grep '2021-10' /var/log/httpd/error_log
注意:在使用这些命令时,可能需要使用 sudo 来获取管理员权限,因为日志文件的权限通常设置为仅允许 root 用户访问。