1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - centos - 正文

君子好学,自强不息!

在centos7上用systemctl配置tomcat8.5

2023-02-25 | centos | 1818ip | 6212°c
A+ A-
 
环境准备
[root@web01 ~]# java -version
openjdk version “1.8.0_181”
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
 
cd /usr/local
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.34/bin/apache-tomcat-8.5.34.tar.gz
tar zxf apache-tomcat-8.5.34.tar.gz
 
vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk
export CLASS_PATH=.:$JAVA_HOME/lib
export CATALINA_HOME=/usr/local/apache-tomcat-8.5.34
export CATALINA_BASE=/usr/local/apache-tomcat-8.5.34
export PATH=$PATH:$JAVA_HOME/bin:$CATLINA_HOME:/bin
source /etc/profile
 
 
tomcat需要增加一个pid文件
在tomcat/bin目录下
vim setenv.sh
#add tomcat pid
CATALINA_PID=”$CATALINA_BASE/tomcat.pid”
#add java opts
JAVA_OPTS=”-server -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m”
 
 
增加tomcat.service
在/usr/lib/systemd/system目录下
vim tomcat.service
[Unit]
Ddescription=Apach Tomcat 8
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/usr/local/apache-tomcat-8.5.34/tomcat.pid
ExecStart=/usr/local/apache-tomcat-8.5.34/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
#User=tomcat
#Group=tomcat
[Install]
WantedBy=multi-user.target
 
 
systemctl enable tomcat
systemctl start tomcat

本文来源:1818IP

本文地址:https://www.1818ip.com/post/32722.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。