1.下载Tomcat 安装包
官网地址:Apache Tomcat® - Apache Tomcat 9 Software Downloadshttps://tomcat.apache.org/download-90.cgi
2.将下载的安装包上传到 Xftp 上,我是直接放到 usr 下了
3.将安装包解压到 /usr/local/
tar -zxvf apache-tomcat-9.0.86.tar.gz -C /usr/local/
注意:现在还 usr 下,要切换到 usr/local/
4.给安装的目录重命名
mv apache-tomcat-9.0.86 tomcat
5.设置开机自启,并进行编辑
将下面内容写入其中
[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=oneshot
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/tomcat/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
6.测试
cd /usr/local/tomcat/bin
./startup.sh
#打开浏览器,访问ip:8080
./shutdown.sh