Apache在CentOS上的日志默認存放在/var/log/httpd/
目錄下,主要包含訪問日志(access_log
)和錯誤日志(error_log
),查看方式如下:
sudo tail -f /var/log/httpd/access_log
(訪問日志)sudo tail -f /var/log/httpd/error_log
(錯誤日志)sudo less /var/log/httpd/access_log
(支持上下翻頁,按q
退出)sudo grep "關鍵字" /var/log/httpd/access_log
(替換為需搜索的內容,如IP、錯誤碼)sudo cat /var/log/httpd/access_log
注意:若日志路徑因配置修改,可通過grep -R "Log" /etc/httpd/
查找實際路徑。部分命令需root
權限,建議加sudo
。