温馨提示×

centos apache怎么重启

小樊
39
2026-10-08 20:54:49
栏目: 智能运维

在 CentOS 上重启 Apache,常用方式如下(根据你的 CentOS 版本选择):

1. CentOS 7 / 8(使用 systemd)

sudo systemctl restart httpd

只重新加载配置(不中断连接):

sudo systemctl reload httpd

查看状态:

sudo systemctl status httpd

2. CentOS 6 及更早(使用 service)

sudo service httpd restart

3. 使用 apachectl(通用)

sudo apachectl restart

或重新加载配置:

sudo apachectl graceful

常见问题

  • 命令未找到:确认已安装 Apache
    sudo yum install httpd
    
  • 开机自启(CentOS 7/8):
    sudo systemctl enable httpd
    

如果你用的是 CentOS Stream 或 自定义编译的 Apache,也可以告诉我,我给你对应方案。

0 踩