Tomcat详解(上)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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。目前jdk版本1.6,1.7,1.8俗称版本6、版本7和版本8。
安装JDK
1、下载安装包
官网下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html,不可以使用wget。
2、解压并移动
[[email protected] src]# tar zxf jdk-8u144-linux-x64.tar.gz [[email protected] src]# mv jdk1.8.0_144 /usr/local/jdk1.8
3、配置环境变量
[[email protected] 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 [[email protected] src]# source /etc/profile
4、检查版本号
[[email protected] src]# java -version java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode) [[email protected] src]# rpm -qa |grep openjdk ##搜索openjdk是否被安装
安装Tomcat
1、下载安装包
[[email protected] src]# cd /usr/local/src [[email protected] src]# wget http://apache.fayea.com/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz
2、解压并移动
[[email protected] src]# tar zxf apache-tomcat-8.5.20.tar.gz [[email protected] src]# mv apache-tomcat-8.5.20 /usr/local/tomcat
3、启动服务
[[email protected] 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.
4、验证效果
[[email protected] src]# ps aux|grep tomcat root 22113 9.5 3.0 3377808 103468 pts/1 Sl 03:18 0:03 /usr/local/jdk1.8/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 -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 22204 0.0 0.0 112648 964 pts/1 S+ 03:18 0:00 grep --color=auto tomcat [[email protected] src]# netstat -lntp|grep java tcp6 0 0 :::8080 :::* LISTEN 22363/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 22363/java tcp6 0 0 :::8009 :::* LISTEN 22363/java
▎三个端口:Tomcat的作用就是监听这三个端口。
8080为提供web服务的端口,
8005为管理端口,
8009端口为第三方服务调用的端口,比如httpd和Tomcat结合时会用到。
5、关闭进程
[[email protected] src]# /usr/local/tomcat/bin/shutdown.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
本文出自 “Gorilla City” 博客,请务必保留此出处http://juispan.blog.51cto.com/943137/1960335
以上是关于Tomcat详解(上)的主要内容,如果未能解决你的问题,请参考以下文章