在 Debian 系统下,重启 Tomcat 的方法取决于你是如何安装和运行的(系统包安装 vs 手动解压安装)。下面给出几种常见方式。
如果你是通过 apt 安装的 Tomcat,或者自己配置了 systemd 服务。
常见服务名:
systemctl list-units --type=service | grep tomcat
一般为:
tomcat9tomcat10tomcatsudo systemctl restart tomcat9
sudo systemctl status tomcat9
sudo systemctl enable tomcat9
如果你是从 Apache 官网下载、解压安装的 Tomcat(如 /opt/tomcat)。
cd /opt/tomcat
./bin/shutdown.sh
如果停止失败,可强制杀进程:
ps -ef | grep tomcat
kill -9 <PID>
./bin/startup.sh
tail -f logs/catalina.out
如果是较老版本 Debian 或仍使用 init.d:
sudo service tomcat restart
或:
/etc/init.d/tomcat restart
ss -lntp | grep 8080
浏览器访问:
http://服务器IP:8080
sudo ufw status
tail -f /opt/tomcat/logs/catalina.out
lsof -i:8080
| 安装方式 | 重启方式 |
|---|---|
| apt 安装 | systemctl restart tomcat9 |
| 手动安装 | shutdown.sh + startup.sh |
| 老系统 | service tomcat restart |
如果你愿意,我可以帮你判断你当前 Tomcat 的安装方式并给出精确命令。