阅读量:4
CentOS LAMP日志查看方法如下:
一、常用命令查看
- journalctl(CentOS 7+):
- 查看所有日志:
journalctl - 查看系统本次启动日志:
journalctl -b - 查看内核日志:
journalctl -k
- 查看所有日志:
- tail:实时查看日志末尾内容,如
tail -f /var/log/httpd/access_log。 - less:分页查看完整日志,如
less /var/log/mysqld.log。 - grep:搜索特定关键字,如
grep "404" /var/log/httpd/access_log。
二、日志文件位置
- 系统日志:
/var/log/messages - Apache日志:
- 访问日志:
/var/log/httpd/access_log - 错误日志:
/var/log/httpd/error_log
- 访问日志:
- MySQL日志:
- 错误日志:
/var/log/mysqld.log或/var/log/mysql/error.log - 慢查询日志:
/var/log/mysql/slow-query.log(需启用)
- 错误日志:
- PHP日志:
- PHP-FPM错误日志:
/var/log/php-fpm/error.log - PHP错误日志(非FPM):
/var/log/php_errors.log或/var/log/httpd/error_log
- PHP-FPM错误日志:
三、工具推荐
- ELK Stack:用于日志的集中分析、可视化(需额外部署)。
- logrotate:管理日志轮转,避免文件过大。
注意:部分命令需sudo权限,日志路径可能因配置不同需调整,可通过php --ini、cat /etc/httpd/conf/httpd.conf等命令确认具体路径。
以上就是关于“centos lamp日志如何查看”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm