centos 7 Apache-Tomcat-8.5.46 安装 Web 应用服务器
tomcat 官网版本地址:https://tomcat.apache.org/whichversion.html
Servlet规格 | JSP规范 | EL规格 | WebSocket规范 | JASPIC规格 | Apache Tomcat版本 | 最新发行版本 | 支持的Java版本 |
---|---|---|---|---|---|---|---|
4.0 | 2.3 | 3.0 | 1.1 | 1.1 | 9.0.x | 9.0.26 | 8及更高版本 |
3.1 | 2.3 | 3.0 | 1.1 | 1.1 | 8.5.x | 条款8.5.46 | 7及更高版本 |
3.1 | 2.3 | 3.0 | 1.1 | 不适用 | 8.0.x(已取代) | 8.0.53(已取代) | 7及更高版本 |
3.0 | 2.2 | 2.2 | 1.1 | 不适用 | 7.0.x | 7.0.96 | 6及更高版本 (WebSocket为7及更高版本) |
2.5 | 2.1 | 2.1 | 不适用 | 不适用 | 6.0.x(已归档) | 6.0.53(已归档) | 5及更高版本 |
2.4 | 2.0 | 不适用 | 不适用 | 不适用 | 5.5.x(已存档) | 5.5.36(存档) | 1.4及更高版本 |
2.3 | 1.2 | 不适用 | 不适用 | 不适用 | 4.1.x(已归档) | 4.1.40(已归档) | 1.3及更高版本 |
2.2 | 1.1 | 不适用 | 不适用 | 不适用 | 3.3.x(已存档) | 3.3.2(已存档) | 1.1及更高版本 |
说明环境:
Server-system :linux-centos 7.6 x86_64
Oracle-Java : jdk-8u221-linux-x64.tar.gz
Apache-tomcat :apache-tomcat-8.5.46.tar.gz
Selinux :disabled | stop
Iptable | Firewall:disabled || stop
1.下载 8.5.x版本
注意:寿命终止仅针对8.0.x。8.5.x不受此公告影响。
apache-tomcat-8.5.46.tar.gz : https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.46/bin/apache-tomcat-8.5.46.tar.gz
下载apache-tomcat-8.5.46.tar.gz | sha512 :9d6243ec47ec0f431c55a612fa6a8fac00262ed2731640ad98628b275221d3e8e241b2fee748196b64029997f4d9f8e63831b43986fedb88a62381a92b05ca68 *apache-tomcat-8.5.46.tar.gz
[root@localhost ~]# wget -P /usr/local/src/ https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.46/bin/apache-tomcat-8.5.46.tar.gz
2.检查 sha512 文件
[root@localhost src]# sha512sum apache-tomcat-8.5.46.tar.gz 9d6243ec47ec0f431c55a612fa6a8fac00262ed2731640ad98628b275221d3e8e241b2fee748196b64029997f4d9f8e63831b43986fedb88a62381a92b05ca68 apache-tomcat-8.5.46.tar.gz
3.解压文件并进入文件目录 :cd $(dirname `tar -zxvf xxxx.tar.gz`)
[root@localhost src]# cd $(dirname `tar -zxvf apache-tomcat-8.5.46.tar.gz`) [root@localhost apache-tomcat-8.5.46]# ls -lt total 124 drwxr-x---. 2 root root 4096 Oct 1 15:10 bin drwxr-x---. 2 root root 4096 Oct 1 15:10 lib drwxr-x---. 2 root root 30 Oct 1 15:10 temp -rw-r-----. 1 root root 19318 Sep 17 02:19 BUILDING.txt drwx------. 2 root root 238 Sep 17 02:19 conf -rw-r-----. 1 root root 5407 Sep 17 02:19 CONTRIBUTING.md -rw-r-----. 1 root root 57011 Sep 17 02:19 LICENSE -rw-r-----. 1 root root 1726 Sep 17 02:19 NOTICE -rw-r-----. 1 root root 3255 Sep 17 02:19 README.md -rw-r-----. 1 root root 7139 Sep 17 02:19 RELEASE-NOTES -rw-r-----. 1 root root 16262 Sep 17 02:19 RUNNING.txt drwxr-x---. 7 root root 81 Sep 17 02:17 webapps drwxr-x---. 2 root root 6 Sep 17 02:17 logs drwxr-x---. 2 root root 6 Sep 17 02:17 work
[root@localhost tomcat]# tree -L 1
.
├── bin #用以启动、关闭Tomcat或者其它功能的脚本(.bat文件和.sh文件)
├── BUilDiNG.txt
├── conf #用以配置Tomcat的XML及DTD文件
├── CONTRiBUTiNG.md
├── lib #存放web应用能访问的JAR包
├── LICENSE #许可证
├── logs #Catalina和其它Web应用程序的日志文件
├── NOTICE
├── README.md
├── RElEASE-NOTES
├── RUNNING.txt
├── temp #临时文件
├── webapps #Web应用程序根目录
└── work #用以产生有JSP编译出的Servlet的.java和.class文件
7 directories, 7 files
[root@localhost ~]# mv /usr/local/src/apache-tomcat-8.5.46 /usr/local/tomcat/
4.下载oracle java jdk 开发者工具
https://www.oracle.com/technetwork/java/javase/downloads/index.html 需要登录接受许可协议
使用winscp或者rz命令上传到 /usr/local/src 目录
解压jdk-8u221-linux-x64.tar.gz
[root@localhost src]# tar -zxvf jdk-8u221-linux-x64.tar.gz [root@localhost src]# mv jdk1.8.0_221/ /usr/local/java/ [root@localhost ~]# ll /usr/local/java/ total 26016 drwxr-xr-x. 2 10 143 4096 Jul 4 19:35 bin -r--r--r--. 1 10 143 3244 Jul 4 19:35 COPYRIGHT drwxr-xr-x. 3 10 143 132 Jul 4 19:35 include -rw-r--r--. 1 10 143 5216468 Jun 12 19:07 javafx-src.zip drwxr-xr-x. 5 10 143 185 Jul 4 19:35 jre drwxr-xr-x. 5 10 143 245 Jul 4 19:35 lib -r--r--r--. 1 10 143 44 Jul 4 19:35 LICENSE drwxr-xr-x. 4 10 143 47 Jul 4 19:35 man -r--r--r--. 1 10 143 159 Jul 4 19:35 README.html -rw-r--r--. 1 10 143 424 Jul 4 19:35 release -rw-r--r--. 1 10 143 21107447 Jul 4 19:35 src.zip -rw-r--r--. 1 10 143 116468 Jun 12 19:07 THIRDPARTYLICENSEREADME-JAVAFX.txt -r--r--r--. 1 10 143 169691 Jul 4 19:35 THIRDPARTYLICENSEREADME.txt
#!/bin/bash #java-srcpit-configure cp /etc/profile /etc/profile.bak echo ' unset i unset -f pathmunge export JAVA_HOME=/usr/local/java export CLASSPATH=.:JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile source /etc/profile echo $? exit 0
[root@localhost ~]# java -version java version "1.8.0_221" Java(TM) SE Runtime Environment (build 1.8.0_221-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
启动tomcat
[root@localhost tomcat]# cd /usr/local/tomcat/bin/ [root@localhost bin]# ./startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/java Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.
[root@localhost bin]# ps -ef|grep tomcat root 4032 1 1 19:15 pts/0 00:00:03 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start root 4105 3854 0 19:19 pts/0 00:00:00 grep --color=auto tomcat [root@localhost bin]# ps -axu|grep tomcat root 4032 1.2 7.7 2290156 76940 pts/0 Sl 19:15 0:03 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start root 4113 0.0 0.0 112712 960 pts/0 S+ 19:20 0:00 grep --color=auto tomcat [root@localhost ~]# netstat -nalp|grep 8080 tcp 0 0 127.0.0.1:15012 127.0.0.1:8080 TIME_WAIT - tcp 0 0 192.168.1.6:45102 192.168.1.6:8080 TIME_WAIT - tcp6 0 0 :::8080 :::* LISTEN 4032/java
[root@localhost bin]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
LISTEN 0 100 :::8009 :::*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::22
C:\Users\9_9\Desktop>tcping.exe 192.168.1.6 8080 Probing 192.168.1.6:8080/tcp - Port is open - time=1.351ms Probing 192.168.1.6:8080/tcp - Port is open - time=7.362ms Probing 192.168.1.6:8080/tcp - Port is open - time=0.502ms Probing 192.168.1.6:8080/tcp - Port is open - time=0.572ms Ping statistics for 192.168.1.6:8080 4 probes sent. 4 successful, 0 failed. (0.00% fail) Approximate trip times in milli-seconds: Minimum = 0.502ms, Maximum = 7.362ms, Average = 2.447ms
检查端口:telnet wget ping ssh curl
[root@localhost bin]# telnet 192.168.1.6 8080 Trying 192.168.1.6... Connected to 192.168.1.6. Escape character is '^]'. ^CConnection closed by foreign host. [root@localhost bin]# wget 192.168.1.6:8080 --2019-10-04 03:46:54-- http://192.168.1.6:8080/ Connecting to 192.168.1.6:8080... connected. HTTP request sent, awaiting response... 200 Length: unspecified [text/html] Saving to: ‘index.html’ [ <=> ] 11,195 --.-K/s in 0s 2019-10-04 03:46:54 (122 MB/s) - ‘index.html’ saved [11195] [root@localhost bin]# ls -la index.html -rw-r--r--. 1 root root 11195 Oct 4 03:46 index.html [root@localhost bin]# curl 192.168.1.6:8080