Ubuntu系统配置tomcat过程
1.本次配置采取ubuntu20.04.3,jdk17,tomcat9,(资源自取)
链接:https://pan.baidu.com/s/17QOpDNWiohRGX4nNY_lLzg
提取码:l0pv
2.将apache-tomcat-9.0.56 重命名为 tomcat
mv apache-tomcat-9.0.56 tomcat
3.将jdk-17.0.1 重命名为 jdk17
mv jdk-17.0.1 jdk17
4.将tomcat移动到/usr/local/文件夹
sudo mv tomcat /usr/local/
5.将jdk17 移动到/usr/local/文件夹
sudo mv jdk17 /usr/local/
6.移动文件并改名
sudo cp /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
sudo chmod 755 /etc/init.d/tomcat
7.修改文件
sudo vim/etc/init.d/tomcat
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network $time
# Should-Stop: $network $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start tomcat daemon at boot time
# Description: Start tomcat daemon at boot time
### END INIT INFO
JAVA_HOME=/usr/local/jdk17
JRE_HOME=/usr/local/jdk17
CATALINA_HOME=/usr/local/tomcat
CATALINA_BASE=/usr/local/tomcat
7.添加到系统自启动
update-rc.d tomcat defaults
sudo systemctl enable tomcat
sudo /lib/systemd/systemd-sysv-install enable tomcat
8.重启查看
sudo reboot
9.更改端口号(可选)
sudo vim /usr/local/tomcat/conf/server.xml
更改默认端口号8080即可
10.tomcat设置
查看tomcat服务是否正常
service tomcat status
重启tomcat服务
service tomcat restart
停止tomcat服务
service tomcat restart
关闭系统自启动
sudo systemctl disable tomcat