在 CentOS 系统中,Apache 的服务名通常是 httpd(而不是 Ubuntu/Debian 中的 apache2)。下面是常见的重启方式:
sudo systemctl restart httpd
开机自启(如需要):
sudo systemctl enable httpd
查看状态:
sudo systemctl status httpd
sudo service httpd restart
sudo /etc/init.d/httpd restart
apache2 这个服务名apache2 的自定义版本(极少情况),可查看:systemctl list-unit-files | grep apache
如不确定 Apache 是否安装,可先执行:
httpd -v
或
rpm -qa | grep httpd
如果你是在 Docker / 编译安装 / 特定环境 中,也可以告诉我,我给你对应方案。