在常见的 Linux 系统(如 Ubuntu / Debian / CentOS)中,查看 Apache2(httpd)状态 通常有下面几种方式:
大多数现代 Linux 都使用 systemd:
systemctl status apache2
(CentOS / RHEL 上服务名是 httpd)
systemctl status httpd
查看是否正在运行、最近日志、PID 等信息。
常用命令:
# 启动
sudo systemctl start apache2
# 停止
sudo systemctl stop apache2
# 重启
sudo systemctl restart apache2
# 开机自启
sudo systemctl enable apache2
sudo service apache2 status
或
sudo service httpd status
ps aux | grep apache2
或
ps aux | grep httpd
Apache 默认监听 80(HTTP)或 443(HTTPS):
sudo netstat -tunlp | grep :80
或
sudo ss -tunlp | grep :80
curl -I http://localhost
或
curl http://127.0.0.1
返回 200 OK 说明 Apache 正常工作。
sudo tail -f /var/log/apache2/error.log
(CentOS 通常在 /var/log/httpd/error_log)
如果你能告诉我:
我可以给你更精确的建议。