安装tomcat8 env
阅读原文时间:2023年07月10日阅读:1

目录

1 download package

wget  https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.65/bin/apache-tomcat-8.5.65.tar.gz -P /tmp

2 install tomcat

tar -xf /tmp/apache-tomcat-8.5.65.tar.gz -C /usr/local
ln -s /usr/local/apache-tomcat-8.5.65/ /usr/local/tomcat

echo 'PATH=/usr/local/tomcat/bin:$PATH' > /etc/profile.d/tomcat.sh
. /etc/profile.d/tomcat.sh
catalina.sh version

3 Pro config

useradd -r -s /sbin/nologin tomcat
cat > /usr/local/tomcat/conf/tomcat.conf eof
JAVA_HOME=/usr/local/jdk
JRE_HOME=/usr/local/jdk/jre
eof

chown -R tomcat. /usr/local/tomcat
cat > /usr/lib/systemd/system/tomcat.service << eof
[Unit]
Description=Tomcat
#After=syslog.target network.target remote-fs.target nss-lookup.target
After=syslog.target network.target

[Service]
Type=forking
EnvironmentFile=/usr/local/tomcat/conf/tomcat.conf
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
PrivateTmp=true
User=tomcat
Group=tomcat

[Install]
WantedBy=multi-user.target
eof

systemctl daemon-reload
systemcat enable --now tomcat

4. docker image

[0 root@centos7 /root]# docker images
REPOSITORY                      TAG                            IMAGE ID       CREATED        SIZE
tomcat                          8.5-jdk8-adoptopenjdk-openj9   5f6e70baad09   3 weeks ago    374MB
[0 root@centos7 /root]# docker run -d  -P --name tomcat tomcat:8.5-jdk8-adoptopenjdk-openj9
c9758fe07e299a8251150f78fc0e1bddcbee42bb633bf36c3d251b4dd03c39b5
[0 root@centos7 /root]# docker exec -it tomcat bash
root@c9758fe07e29:/usr/local/tomcat# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

root@c9758fe07e29:/usr/local/tomcat# catalina.sh version
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /opt/java/openjdk
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Server version: Apache Tomcat/8.5.65
Server built:   Mar 30 2021 12:28:40 UTC
Server number:  8.5.65.0
OS Name:        Linux
OS Version:     3.10.0-1160.el7.x86_64
Architecture:   amd64
JVM Version:    1.8.0_282-b08
JVM Vendor:     Eclipse OpenJ9

root@c9758fe07e29:/usr/local/tomcat# java -version
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-b08)
Eclipse OpenJ9 VM (build openj9-0.24.0, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20210120_930 (JIT enabled, AOT enabled)
OpenJ9   - 345e1b09e
OMR      - 741e94ea8
JCL      - ab07c6a8fd based on jdk8u282-b08)