温馨提示×

centos如何重启apache服务

小樊
37
2026-10-03 00:26:13
栏目: 智能运维

在 CentOS 中重启 Apache 服务的方法取决于你的 CentOS 版本以及 Apache 的服务名(通常是 httpd)。

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

sudo systemctl restart httpd

其他常用命令:

sudo systemctl start httpd     # 启动
sudo systemctl stop httpd      # 停止
sudo systemctl status httpd    # 查看状态

2. 使用 service(CentOS 6 及以前)

sudo service httpd restart

3. 设置开机自启(可选)

sudo systemctl enable httpd

4. 如果 Apache 是通过源码或其他方式安装的

服务名可能不是 httpd,可以先查看:

systemctl list-unit-files | grep apache

或者:

ps aux | grep httpd

如果还有问题,可以贴一下你的 CentOS 版本和报错信息。

0 踩