在 CentOS 中重启 Apache 服务的方法取决于你的 CentOS 版本以及 Apache 的服务名(通常是 httpd)。
sudo systemctl restart httpd
其他常用命令:
sudo systemctl start httpd # 启动
sudo systemctl stop httpd # 停止
sudo systemctl status httpd # 查看状态
sudo service httpd restart
sudo systemctl enable httpd
服务名可能不是 httpd,可以先查看:
systemctl list-unit-files | grep apache
或者:
ps aux | grep httpd
如果还有问题,可以贴一下你的 CentOS 版本和报错信息。