在 CentOS 上重启 Apache(httpd) 服务,根据你使用的 CentOS 版本 不同,命令略有区别。
sudo systemctl restart httpd
sudo systemctl start httpd
sudo systemctl stop httpd
sudo systemctl reload httpd
sudo systemctl status httpd
sudo systemctl enable httpd
sudo service httpd restart
httpd -t
# 或
apachectl configtest
✅ 如果输出 Syntax OK,说明配置没有问题。
| 项目 | 路径 |
|---|---|
| Apache 主配置 | /etc/httpd/conf/httpd.conf |
| 虚拟主机配置 | /etc/httpd/conf.d/ |
| 网站根目录 | /var/www/html |
| 日志目录 | /var/log/httpd/ |
ss -lntp | grep 80
tail -f /var/log/httpd/error_log
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
如果你愿意,可以告诉我:
我可以帮你精确判断 是否需要重启还是 reload 即可。