温馨提示×

centos怎样重启apache2

小樊
37
2026-10-17 14:33:31
栏目: 智能运维

在 CentOS 系统中,Apache 的服务名通常是 httpd(而不是 Ubuntu/Debian 中的 apache2)。下面是常见的重启方式:

1. 使用 systemctl(CentOS 7 及以上)

sudo systemctl restart httpd

开机自启(如需要):

sudo systemctl enable httpd

查看状态:

sudo systemctl status httpd

2. 使用 service(兼容旧版本)

sudo service httpd restart

3. 如果是 CentOS 6 及更早版本

sudo /etc/init.d/httpd restart

补充说明

  • CentOS 默认 没有 apache2 这个服务名
  • 如果你确实安装了名为 apache2 的自定义版本(极少情况),可查看:
systemctl list-unit-files | grep apache

如不确定 Apache 是否安装,可先执行:

httpd -v

或

rpm -qa | grep httpd

如果你是在 Docker / 编译安装 / 特定环境 中,也可以告诉我,我给你对应方案。

0 踩