在 Ubuntu 上查看 Apache2(apache2)服务状态,常用以下几种方法:
systemctl status apache2
常见输出说明:
active (running):正在运行inactive (dead):已停止failed:启动失败按 q 退出查看。
service apache2 status
ps aux | grep apache2
或
pgrep apache2
sudo netstat -tulnp | grep apache2
或(新系统)
sudo ss -tulnp | grep apache2
curl http://localhost
或
curl http://127.0.0.1
返回 HTML 页面说明 Apache 正常工作。
sudo tail -f /var/log/apache2/error.log
sudo systemctl start apache2 # 启动
sudo systemctl stop apache2 # 停止
sudo systemctl restart apache2 # 重启
sudo systemctl enable apache2 # 开机自启
如果你是想确认是否安装成功或排查无法访问问题,可以告诉我具体现象。