下载tomcat 9.0版本
wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.30/bin/apache-tomcat-9.0.30.tar.gz
https://download.csdn.net/download/zhanremo3062/15118261
解压
tar zxvf apache-tomcat-9.0.30.tar.gz
调整位置
mv apache-tomcat-9.0.30 /usr/local/tomcat
进入目录
cd /usr/local/tomcat/
编辑配置文件,添加pid文件
vim bin/catalina.sh
添加:
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
编辑系统启动服务文件
vim /etc/systemd/system/tomcat9.service
[Unit] Description=Apache Tomcat Web Application Container After=syslog.target network.target [Service] Type=forking Environment=JAVA_HOME=/usr/local/java/ Environment=CATALINA_HOME=/usr/local/tomcat/ Environment=CATALINA_BASE=/usr/local/tomcat/ Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC' Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom' Environment=CATALINA_PID=/usr/local/tomcat/tomcat.pid ExecStart=/usr/local/tomcat/bin/startup.sh ExecStop=/usr/local/tomcat/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID PrivateTmp=true User=tomcat Group=tomcat [Install] WantedBy=multi-user.target
添加权限
chmod a+x /etc/systemd/system/tomcat9.service chmod a+x /usr/local/tomcat/bin/* useradd -rs /bin/false tomcat chown -R tomcat.tomcat /usr/local/tomcat
启动tomcat
systemctl start tomcat9.service