温馨提示×

如何查看ubuntu apache2状态

小樊
37
2026-10-02 06:08:40
栏目: 智能运维

在 Ubuntu 上查看 Apache2(apache2)服务状态,常用以下几种方法:


1. 使用 systemctl(推荐,Ubuntu 16.04+)

systemctl status apache2

常见输出说明:

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

按 q 退出查看。


2. 使用 service 命令(兼容旧版本)

service apache2 status

3. 查看 Apache 进程

ps aux | grep apache2

或

pgrep apache2

4. 查看端口监听状态(确认是否在监听 80/443)

sudo netstat -tulnp | grep apache2

或(新系统)

sudo ss -tulnp | grep apache2

5. 通过浏览器或 curl 测试

curl http://localhost

或

curl http://127.0.0.1

返回 HTML 页面说明 Apache 正常工作。


6. 查看 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   # 开机自启

如果你是想确认是否安装成功或排查无法访问问题,可以告诉我具体现象。

0 踩