在 Ubuntu 上停止 Apache 服务,常用以下几种方式(适用于 Apache 2,Ubuntu 16.04+):
sudo systemctl stop apache2
sudo systemctl status apache2
sudo service apache2 stop
sudo systemctl stop apache2
sudo systemctl disable apache2
查看是否已禁用:
systemctl is-enabled apache2
sudo apachectl stop
需要确认
apachectl在 PATH 中,且权限足够
ss -tlnp | grep :80
# 或
curl -I http://localhost
sudo lsof -i :80
sudo kill -9 <PID>
| 需求 | 命令 |
|---|---|
| 停止 Apache | sudo systemctl stop apache2 |
| 禁止开机启动 | sudo systemctl disable apache2 |
| 查看状态 | systemctl status apache2 |
如果你是想 临时关闭测试、重启 Apache 或 完全卸载 Apache,可以告诉我具体场景,我可以给你更合适的方案。