标签:Linux学习
16.1 Tomcat介绍Tomcat是Apache软件基金会(Apache Software Foundation)的Jakarta项目中的一个核心项目,由Apache、Sun和其他一些公司及个人共同开发而成。
java程序写的网站用tomcat+jdk来运行
tomcat是一个中间件,真正起作用的,解析java脚本的是jdk
jdk(java development kit)是整个java的核心,它包含了java运行环境和一堆java相关的工具以及java基础库。
最主流的jdk为sun公司发布的jdk,除此之外,其实IBM公司也有发布JDK,CentOS上也可以用yum安装openjdk
16.2 安装jdk
jdk版本1.6,1.7,1.8
官网下载地址 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载jdk8,放到/usr/local/src/目录下
tar zxvf jdk-8u144-linux-x64.tar.gz
mv jdk1.8.0_144 /usr/local/jdk1.8
vi /etc/profile //最后面增加
JAVA_HOME=/usr/local/jdk1.8/
JAVA_BIN=/usr/local/jdk1.8/bin
JRE_HOME=/usr/local/jdk1.8/jre
PATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin
CLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar
source /etc/profile
java -version
操作过程
[root@linux-01 src]# cd /usr/local/src/
[root@linux-01 src]# wget wget http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz?AuthParam=1523420448_20afcbdad3898c967abd73288200d41d
[root@linux-01 src]# tar zxvf jdk-8u161-linux-x64.tar.gz
[root@linux-01 src]# du -sh jdk1.8.0_161/
371M jdk1.8.0_161/
[root@linux-01 src]# mv jdk1.8.0_161/ /usr/local/jdk1.8
[root@linux-01 src]# vim /etc/profile
添加到最后
JAVA_HOME=/usr/local/jdk1.8/
JAVA_BIN=/usr/local/jdk1.8/bin
JRE_HOME=/usr/local/jdk1.8/jre
PATH=$PATH:/usr/local/jdk1.8/bin:/usr/local/jdk1.8/jre/bin
CLASSPATH=/usr/local/jdk1.8/jre/lib:/usr/local/jdk1.8/lib:/usr/local/jdk1.8/jre/lib/charsets.jar
[root@linux-01 src]# source /etc/profile
[root@linux-01 src]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
系统如果有安装openjdk,不能卸载
[root@linux-01 src]# rpm -qa |grep openjdk
[root@linux-01 src]# yum list|grep openjdk
16.3 安装Tomcat
cd /usr/local/src
wget http://apache.fayea.com/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz
tar zxvf apache-tomcat-8.5.20.tar.gz
mv apache-tomcat-8.5.20 /usr/local/tomcat
/usr/local/tomcat/bin/startup.sh
ps aux|grep tomcat
netstat -lntp |grep java
三个端口8080为提供web服务的端口,8005为管理端口,8009端口为第三方服务调用的端口,比如httpd和Tomcat结合时会用到
操作过程
[root@linux-01 src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.7/bin/apache-tomcat-9.0.7.tar.gz
[root@linux-01 src]# ll apache-tomcat-9.0.7.tar.gz
-rw-r--r--. 1 root root 9517889 4月 4 04:19 apache-tomcat-9.0.7.tar.gz
[root@linux-01 src]# tar zxvf apache-tomcat-9.0.7.tar.gz
[root@linux-01 src]# mv apache-tomcat-9.0.7 /usr/local/tomcat
[root@linux-01 src]# /usr/local/tomcat/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/jdk1.8
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@linux-01 src]# ps aux|grep tomcat
[root@linux-01 src]# netstat -lntp|grep java
tcp6 0 0 :::8009 :::* LISTEN 11484/java
tcp6 0 0 :::8080 :::* LISTEN 11484/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 11484/java
[root@linux-01 src]# systemctl stop firewalld.service
[root@linux-01 src]# iptables -nvL
浏览器打开 http://192.168.106.160:8080/ 显示 Apache Tomcat/9.0.7 正常
标签:Linux学习
原文地址:http://blog.51cto.com/9298822/2116299