Debian上JSP应用部署流程解析
一 环境准备与安装
sudo apt update && sudo apt install openjdk-11-jdk,验证:java -version。sudo apt install tomcat9。如需管理界面,可同时安装:sudo apt install tomcat9-admin。sudo systemctl start tomcat9 && sudo systemctl enable tomcat9。二 部署方式
sudo cp myapp.war /var/lib/tomcat9/webapps/,访问 http://服务器IP:8080/myapp。三 依赖管理与构建
sudo apt install maven,在项目根目录执行 mvn clean package,生成的 WAR 放入 webapps。sudo apt install gradle,执行 gradle build 产出 WAR 后部署。四 数据库与连接配置
sudo ufw allow 3306/tcp(数据库端口,仅对应用与数据库间开放为宜)。五 网络访问 日志与安全加固
sudo ufw allow 8080/tcp。tail -f /var/log/tomcat9/catalina.out。sudo apt install certbot python3-certbot-nginx 获取证书,然后配置 Nginx 反向代理到 http://localhost:8080。<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="/etc/letsencrypt/live/your_domain.com/fullchain.pem"
certificateKeystorePassword="your_keystore_password" type="RSA"/>
</SSLHostConfig>
</Connector>
修改后重启 Tomcat:sudo systemctl restart tomcat9。