- 自行到Apache官网下载tomcat8.5.60或直接使用wget下载.后解压到 /usr/local/tomcat8 目录.
wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.60/bin/apache-tomcat-8.5.60.tar.gz ->下载安装包,自行下载可忽略此步骤,自行下载并上传到服务器上. tar -zxvf apache-tomcat-8.5.42.tar.gz ->解压安装包 mv apache-tomcat-8.5.42 /usr/local/tomcat8 ->移动到/usr/local
-
修改配置文件
/usr/local/tomcat8 ->进入到解压目录
vi bin/catalina.sh ->修改catalina.sh配置文件
找到OS specific support,在这一行前面添加以下内容,修改好后保存文件并退出(按顺序按下 Esc -> Shift+:->w ->q ->Enter键保存并退出)
JAVA_HOME=/usr/local/jdk1.8.0_212 #此处替换成你自己的jdk路径
JRE_HOME=$JAVA_HOME/jre
-
配置tomcat8开机启动
在/usr/lib/systemd/system目录下增加tomcat8.service文件
vi /usr/lib/systemd/system/tomcat8.service
按i或者Insert键输入以下内容保存并退出:
[Unit] Description=Tomcat-8 After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=oneshot ExecStart=/usr/local/tomcat8/bin/startup.sh ExecStop=/usr/local/tomcat8/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target
设置开机自启动:
systemctl enable tomcat8.service ->开机自启tomcat systemctl start tomcat8.service ->启动tomcat
-
tomcat8常见命令扩展
systemctl enable tomcat8.service ->开机自启tomcat systemctl disable tomcat8.service ->禁用开机自启tomcat systemctl start tomcat8.service ->启动tomcat systemctl stop tomcat8.service ->关闭tomcat systemctl restart tomcat8.service ->重启tomcat systemctl status tomcat8.service ->查看状态tomcat
[Unit]Description=Tomcat-8After=syslog.target network.target remote-fs.target nss-lookup.target [Service]Type=oneshotExecStart=/usr/local/tomcat8/bin/startup.shExecStop=/usr/local/tomcat8/bin/shutdown.shExecReload=/bin/kill -s HUP $MAINPIDRemainAfterExit=yes
[Install]WantedBy=multi-user.target