温馨提示×

centos下apache2怎样重启

小樊
44
2026-09-11 21:22:05
栏目: 智能运维

CentOS 下,Apache 通常叫 httpd(而不是 apache2,apache2 是 Debian/Ubuntu 的叫法)。

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

# 重启
systemctl restart httpd

# 启动
systemctl start httpd

# 停止
systemctl stop httpd

# 查看状态
systemctl status httpd

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

service httpd restart

3. 设置开机自启

systemctl enable httpd

补充说明

  • 如果你确实安装的是 apache2(极少见于 CentOS),可以尝试:
    systemctl restart apache2
    
  • 修改配置后建议先测试:
    apachectl configtest
    
    显示 Syntax OK 再重启。

如果你是 Docker / 编译安装 / 特定面板(如宝塔),可以告诉我,我给你对应的重启方式。

0