温馨提示×

centos如何查看apache2状态

小樊
42
2026-09-27 03:30:51
栏目: 智能运维

在 CentOS 上,Apache 的服务名通常是 httpd(不是 apache2,apache2 多见于 Ubuntu/Debian)。

1. 查看 Apache 运行状态(推荐)

systemctl status httpd

输出中可以看到:

  • active (running) → 正在运行
  • inactive (dead) → 未运行

2. 查看是否开机自启

systemctl is-enabled httpd
  • enabled → 开机自启
  • disabled → 不开机自启

3. 启动 / 停止 / 重启

systemctl start httpd     # 启动
systemctl stop httpd      # 停止
systemctl restart httpd   # 重启

4. 查看进程

ps aux | grep httpd

或

ps -ef | grep httpd

5. 查看监听端口(默认 80)

netstat -lntp | grep httpd

或(新系统)

ss -lntp | grep httpd

6. 查看 Apache 版本

httpd -v

如果你确实安装的是 apache2(极少见),可以先确认:

systemctl list-unit-files | grep apache

然后对应使用:

systemctl status apache2

如果你是想确认 Web 是否能访问,也可以:

curl http://localhost

需要我帮你判断 Apache 是否安装、或排错启动失败吗?

0 踩