温馨提示×

如何查debian apache2状态

小樊
38
2026-09-30 14:48:36
栏目: 智能运维

在 Debian 系统上,Apache2 通常是通过 systemd 来管理的,所以最常见、推荐的方式是使用 systemctl 命令。


一、查看 Apache2 运行状态(最常用)

sudo systemctl status apache2

你会看到类似信息:

  • active (running):正在运行
  • inactive (dead):已停止
  • failed:启动失败

按 q 退出查看。


二、检查 Apache2 是否在运行(简洁方式)

systemctl is-active apache2

输出:

  • active → 正在运行
  • inactive → 未运行

三、查看 Apache 进程

ps aux | grep apache2

或

pgrep -a apache2

四、查看 Apache 监听端口

sudo ss -tulnp | grep apache2

或(旧系统)

sudo netstat -tulnp | grep apache2

通常监听:

  • 80(http)
  • 443(https)

五、检查 Apache 配置文件是否正确

sudo apache2ctl configtest

输出:

  • Syntax OK → 配置正常
  • 否则会提示错误位置

六、启动 / 停止 / 重启 Apache2

sudo systemctl start apache2     # 启动
sudo systemctl stop apache2      # 停止
sudo systemctl restart apache2   # 重启
sudo systemctl reload apache2    # 重新加载配置(不中断连接)

七、设置开机自启

sudo systemctl enable apache2

查看是否开机自启:

systemctl is-enabled apache2

如果你遇到 Apache 起不来 / 端口被占用 / 配置报错,可以把 systemctl status apache2 或 journalctl -xe 的输出发出来,我可以帮你具体看。

0 踩