tomcat介紹,jdk,tomcat安裝
阿新 • • 發佈:2018-06-26
變量 tar zxvf 發布 fire grep tar str net isa 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安裝
- jdk版本1.6,1.7,1.8
- 官網下載地址 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
- 下載jdk8,放到/usr/local/src/目錄下,(先下載到電腦再使用xftp5傳輸)
- 解壓並移動到/usr/local/jdk1.8
[root@akuilinux01 src]# tar zxvf jdk-8u171-linux-x64.tar.gz [root@akuilinux01 src]# mv jdk1.8.0_171/ /usr/local/jdk1.8
- 設置環境變量
[root@akuilinux01 src]# vim /etc/profile AVA_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並驗證
root@akuilinux01 src]# source /etc/profile [root@akuilinux01 src]# java -version java version "1.8.0_171" Java(TM) SE Runtime Environment (build 1.8.0_171-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
- 如果和你安裝的版本不一樣,可以查看是不是安裝過其他版本的jdk,可以卸載其他版本的包,在線上的機器別輕易卸載,可能有些服務用到。
tomcat安裝
- 下載並解壓二進制包
[root@akuilinux01 src]# cd /usr/local/src/ [root@akuilinux01 src]# wget http://apache.fayea.com/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz [root@akuilinux01 src]# tar zxvf apache-tomcat-8.5.31.tar.gz
- 移動並啟動
[root@akuilinux01 src]# mv apache-tomcat-8.5.31 /usr/local/tomcat [root@akuilinux01 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@akuilinux01 src]# ps aux |grep java root 3304 56.0 5.4 4058116 101556 pts/0 Sl 21:55 0:13 /usr/local/jdk1.8/bin/java -Djav.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 3355 0.0 0.0 112676 984 pts/0 S+ 21:56 0:00 grep --color=auto
- tomcat不支持restart,關閉命令為下
[root@akuilinux01 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 [root@akuilinux01 src]# ps aux |grep java root 3391 0.0 0.0 112676 984 pts/0 S+ 21:57 0:00 grep --color=auto java
- 監聽的端口
[root@akuilinux01 ~]# netstat -lntp |grep java tcp6 0 0 :::8080 :::* LISTEN 3407/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 3407/java tcp6 0 0 :::8009 :::* LISTEN 3407/java
- 三個端口8080為提供web服務的端口,8005為管理端口,8009端口為第三方服務調用的端口,比如httpd和Tomcat結合時會用到
- 關閉防火墻就可以瀏覽器打開http://192.168.21.128:8080/,就可以看到tomcat的頁面
[root@akuilinux01 ~]# systemctl stop firewalld [root@akuilinux01 ~]# systemctl disable firewalld [root@akuilinux01 ~]# iptables -nvL Chain INPUT (policy ACCEPT 14339 packets, 206M bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 11657 packets, 1493K bytes) pkts bytes target prot opt in out source destination
擴展
- java容器比較(
http://www.360doc.com/content/11/0618/21/16915_127901371.shtml)
tomcat介紹,jdk,tomcat安裝