以下是CentOS下排查Nginx故障的常用方法:
systemctl status nginx # 查看Nginx是否运行
tail -f /var/log/nginx/error.log # 实时查看错误日志,定位具体错误(如权限、配置错误等)
nginx -t # 检查配置文件是否有语法错误,根据提示修复
sudo netstat -tulnp | grep ':80\|:443' # 确认端口未被其他进程占用,冲突时修改Nginx端口或停止占用进程
chown -R nginx:nginx /var/www/html # 确保Nginx用户有权访问网站目录
systemctl status php-fpm # 检查后端服务状态
df -h、free -h、topfirewall-cmd --add-port=80/tcp --permanentstrace跟踪系统调用:sudo strace -p $(pgrep nginx) -e trace=networkcurl或wget测试访问:curl -I http://localhost参考来源: