1、对java+maven+tomcat三个安装包解压
root@server:/opt
apache-maven-3.5.4 apache-maven-3.5.4-bin.tar.gz apache-tomcat-9.0.71 apache-tomcat-9.0.71.tar.gz jdk1.8.0_211 jdk-8u211-linux-x64.tar.gz
2、环境变量配置
root@server:/opt
export JAVA_HOME=/opt/jdk1.8.0_211
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}
export MAVEN_HOME=/opt/apache-maven-3.5.4
export PATH=$MAVEN_HOME/bin:$PATH
export TOMCAT_HOME=/opt/apache-tomcat-9.0.71
export CATALINA_HOME=/opt/apache-tomcat-9.0.71
root@server:/opt
root@server:/opt
root@server:/opt
3、对tomcat的启动和关闭脚本的JAVA_HOME和JRE_HOME设置
vi /opt/apache-tomcat-9.0.71/bin/setclasspath.sh
export JAVA_HOME=/opt/jdk1.8.0_211
export JRE_HOME=${JAVA_HOME}/jre
4、设置tomcat开机自启
vi /etc/systemd/system/tomcat9.service
[Unit]
Description=Tomcat 9 servlet container
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/opt/jdk1.8.0_211
Environment=CATALINA_PID=/opt/apache-tomcat-9.0.71/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/apache-tomcat-9.0.71
Environment=CATALINA_BASE=/opt/apache-tomcat-9.0.71
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/opt/apache-tomcat-9.0.71/bin/startup.sh
ExecStop=/opt/apache-tomcat-9.0.71/bin/shutdown.sh
User=root
Group=root
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable tomcat9
systemctl start tomcat9
systemctl status tomcat9
5、Linux系统时间与Tomcat日志时间不一致
vi catalina.sh
export JAVA_OPTS="$JAVA_OPTS -Duser.timezone=Asia/shanghai"