# 对于Apache
systemctl status apache2 # 或 httpd
# 对于Nginx
systemctl status nginx
# Apache日志
tail -n 50 /var/log/apache2/error.log # 或 /var/log/httpd/error_log
# Nginx日志
tail -n 50 /var/log/nginx/error.log
netstat -tulnp | grep ':80\|:443'
ss -tulnp | grep ':80\|:443'
可能原因: - 内存不足 - 配置错误 - 模块冲突
解决方法:
# 重启服务
sudo systemctl restart apache2 # 或 nginx
# 检查配置语法
sudo apachectl configtest # 对于Apache
sudo nginx -t # 对于Nginx
可能原因: - 文件权限问题 - 目录索引设置 - SELinux策略限制
解决方法:
# 检查文件权限
ls -la /var/www/html/
# 设置正确权限
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
# 检查SELinux状态
getenforce
sudo setenforce 0 # 临时关闭SELinux(测试用)
解决方法:
# 检查当前连接数
netstat -an | grep ':80' | wc -l
# 调整Apache的最大连接数(MaxClients)
# 编辑/etc/apache2/apache2.conf或/etc/httpd/conf/httpd.conf
# 对于Nginx,调整worker_connections
# 编辑/etc/nginx/nginx.conf
sudo strace -p $(pgrep apache2 | head -1) # 对于Apache
sudo strace -p $(pgrep nginx | head -1) # 对于Nginx
top
free -m
df -h
sudo iptables -L -n
sudo ufw status # 如果使用UFW
如需更具体的帮助,请提供您的Web服务器类型(Apache/Nginx等)和具体的错误日志内容。