在 Debian 系统上停止 Apache Tomcat 有多种方式,取决于你是如何安装和配置 Tomcat 的。下面按常见情况分别说明。
systemctl(最常见,推荐)如果 Tomcat 是通过 systemd 管理的(例如使用官方包或手动配置为服务):
sudo systemctl stop tomcat
注意:
tomcat可能是tomcat9、tomcat10等,具体取决于版本,例如:
sudo systemctl stop tomcat9
查看服务名:
systemctl list-units --type=service | grep tomcat
如果你是从 Apache 官网下载解压安装的 Tomcat:
cd /opt/tomcat/bin
./shutdown.sh
或指定完整路径:
/opt/tomcat/bin/shutdown.sh
前提:
CATALINA_HOME和JAVA_HOME已正确配置。
如果 shutdown.sh 无效或 Tomcat 卡死:
ps -ef | grep tomcat
或:
pgrep -f tomcat
kill PID
kill -9 PID
⚠️ 不推荐优先使用 -9,可能导致数据或会话丢失。
systemctl status tomcat
或:
ps -ef | grep tomcat
也可以访问:
http://localhost:8080
如果无法访问,说明已停止。
Debian 常见包名:
tomcat9tomcat10停止方式:
sudo systemctl stop tomcat9
禁用开机启动(可选):
sudo systemctl disable tomcat9
| 场景 | 停止方式 |
|---|---|
| Debian 包安装 | systemctl stop tomcat9 |
| 手动解压安装 | bin/shutdown.sh |
| 服务无响应 | kill PID |
| 查看状态 | systemctl status tomcat |
如果你愿意,可以告诉我:
我可以给你更精确的命令。