在 Debian 系统上,Apache2 通常是通过 systemd 来管理的,所以最常见、推荐的方式是使用 systemctl 命令。
sudo systemctl status apache2
你会看到类似信息:
active (running):正在运行inactive (dead):已停止failed:启动失败按 q 退出查看。
systemctl is-active apache2
输出:
active → 正在运行inactive → 未运行ps aux | grep apache2
或
pgrep -a apache2
sudo ss -tulnp | grep apache2
或(旧系统)
sudo netstat -tulnp | grep apache2
通常监听:
80(http)443(https)sudo apache2ctl configtest
输出:
Syntax OK → 配置正常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 的输出发出来,我可以帮你具体看。