Tomcat介紹及安裝
阿新 • • 發佈:2018-03-29
TomcatTomcat介紹
安裝jdk
1.下載jdk包,並放到、usr/local/src目錄下:
[root@weix-01 src]# ls
httpd-2.2.34 httpd-2.4.29.tar.gz
httpd-2.2.34.tar.gz jdk-8u161-linux-x64.tar.gz
httpd-2.4.29 mysql-5.6.36-linux-glibc2.5-x86_64.tar.g
2.進行解壓:
[root@weix-01 src]# tar zxvf jdk-8u161-linux-x64.tar.gz
3.移動位置並改名:
[root@weix-01 src]# mv jdk1.8.0_161/ /usr/local/jdk1.8
4.編輯環境變量配置文件:
[root@weix-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
5.重置讓變量生效:
[root@weix-01 src]# source /etc/profile
6.測試是否安裝成功:
[root@weix-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)
安裝Tomcat
1.下載安裝包:
[root@weix-01 src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.29/bin/apache-tomcat-8.5.29.tar.gz
2.解壓縮:
[root@weix-01 src]# tar zxvf apache-tomcat-8.5.29.tar.gz
3.移動位置:
[root@weix-01 src]# mv apache-tomcat-8.5.29 /usr/local/tomcat
4.啟動服務:
[root@weix-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.
5.檢查進程:
[root@weix-01 src]# ps aux |grep java
root 1388 17.9 8.3 2294712 83400 pts/0 Sl 16:53 0:04 /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 -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 1432 0.0 0.0 112676 980 pts/0 R+ 16:53 0:00 grep --color=auto java
6.關閉服務:不支持restart,要關閉再啟動
[root@weix-01 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
7.查看端口:8080,為web服務提供端口,8005為管理端口,8009為第三方調用端口
[root@weix-01 src]# netstat -lntp |grep java
tcp6 0 0 :::8080 :::* LISTEN 1475/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 1475/java
tcp6 0 0 :::8009 :::* LISTEN 1475/java
Tomcat介紹及安裝