CentOS7安装部署tomcat8并配置开机自启动
(1)到Apache官网下载tomcat8.5.50或直接使用wget下载
下载地址:https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz
wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz
(2)将安装包上传至服务器/data目录下,如没有该目录请先创建
mkdir /data
(3)解压tomcat安装包
cd /data tar -zxvf apache-tomcat-8.5.50.tar.gz
(4)修改配置文件bin/catalina.sh
cd apache-tomcat-8.5.50 vi bin/catalina.sh
找到OS specific support,在这一行前面添加以下内容,修改好后保存文件并退出
JAVA_HOME=/data/jdk1.8.0_191 #此处替换成自己的jdk路径 JRE_HOME=$JAVA_HOME/jre
(5)配置服务开机自启动
vi /usr/lib/systemd/system/tomcat.service
输入以下内容保存并退出:
[Unit] Description=Tomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=oneshot ExecStart=/data/apache-tomcat-8.5.50/bin/startup.sh ExecStop=/data/apache-tomcat-8.5.50/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target
设置开机自启动
systemctl daemon-reload systemctl enable tomcat #开机自动启动
(6)启动tomcat服务
systemctl start tomcat.service #启动服务