CentOS下排查Nginx故障可按以下步骤进行:
systemctl status nginx # 查看Nginx是否运行
tail -f /var/log/nginx/error.log # 实时查看错误日志,定位具体错误
nginx -t # 检查配置文件是否有语法错误,如缺少分号、括号不匹配等
netstat -tulnp | grep ':80\|:443' # 确认Nginx监听端口未被其他进程占用
nginx或www-data)对网站目录、日志文件有读写权限:chown -R nginx:nginx /var/www/html
chmod -R 755 /var/www/html
systemctl status php-fpm # 以PHP-FPM为例
top、df -h查看CPU、内存、磁盘空间是否充足。firewall-cmd --add-port=80/tcp --permanent # CentOS 7+
strace跟踪Nginx进程系统调用,分析异常行为。journalctl -u nginx)获取更多上下文信息。参考来源: