一、安装tomcat
下载apache-tomcat-8.5.39.tar.gz,上传到linux目录/usr/local
tar -zxvf apache-tomcat-8.5.39.tar.gz 解压
二、修改tomcat的catalina.sh文件,
vim apache-tomcat-8.5.39/bin/catalina.sh
:set number 添加:CATALINA_PID="$CATALINA_BASE/tomcat.pid"
三、/usr/lib/systemd/system下创建文件tomcat.service
vim tomcat.service
内容为:
[Unit]
Description=tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/local/java/jdk1.8.0_171"
PIDFile=/usr/local/apache-tomcat-8.5.39/tomcat.pid
ExecStart=/usr/local/apache-tomcat-8.5.39/bin/startup.sh
ExecStop=/usr/local/apache-tomcat-8.5.39/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
四、启动tomcat
systemctl enable tomcat 开机启动
systemctl start/stop/ restart tomcat 开始/停止/重启 tomcat
发表评论