阅读量:3
排查 CentOS 上的 LNMP(Linux, Nginx, MySQL, PHP)故障可以通过以下步骤进行:
1. 检查 Nginx 状态
- 查看 Nginx 服务状态:
systemctl status nginx - 检查 Nginx 错误日志:
tail -f /var/log/nginx/error.log
2. 检查 MySQL 状态
- 查看 MySQL 服务状态:
systemctl status mysqld - 检查 MySQL 错误日志:
tail -f /var/log/mysqld.log
3. 检查 PHP 状态
- 查看 PHP-FPM 状态(如果使用 PHP-FPM):
systemctl status php-fpm - 检查 PHP 错误日志:
tail -f /var/log/php-fpm/error.log
4. 检查文件权限
- 确保 Nginx 用户有权限访问网站目录:
chown -R nginx:nginx /path/to/your/website chmod -R 755 /path/to/your/website
5. 检查 SELinux 设置
- 查看 SELinux 状态:
sestatus - 如果 SELinux 启用,检查相关日志:
tail -f /var/log/audit/audit.log | grep avc
6. 检查网络连接
- 使用
ping命令检查服务器是否可达:ping your_server_ip - 使用
telnet或nc检查端口是否开放:telnet your_server_ip 80 # 或者 nc -zv your_server_ip 80
7. 检查防火墙设置
- 查看防火墙状态:
firewall-cmd --state - 检查防火墙规则:
firewall-cmd --list-all
8. 检查 DNS 设置
- 使用
nslookup或dig检查域名解析:nslookup yourdomain.com # 或者 dig yourdomain.com
9. 检查 PHP 配置
- 查看
php.ini文件:cat /etc/php.ini - 检查 PHP 扩展是否加载:
php -m
10. 检查 Nginx 配置
- 查看 Nginx 配置文件:
cat /etc/nginx/nginx.conf - 检查是否有语法错误:
nginx -t
11. 重启服务
- 重启 Nginx:
systemctl restart nginx - 重启 MySQL:
systemctl restart mysqld - 重启 PHP-FPM(如果使用 PHP-FPM):
systemctl restart php-fpm
通过以上步骤,你可以逐步排查并解决 CentOS 上的 LNMP 故障。如果问题依然存在,可以考虑查看系统日志或寻求社区帮助。
以上就是关于“如何排查centos lnmp故障”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm