在官网下载jdk tar包和tomcat tar包
[[email protected] ~]# mkdir /usr/local/java
[[email protected] ~]# tar -zxvf jdk-8u25-linux-x64.tar.gz
[[email protected] ~]# mv jdk1.8.0_25/* /usr/local/java/
设置java 环境变量
[[email protected] ~]# cp /etc/profile /etc/profile.bk
[[email protected] ~]# vi /etc/profile
export JAVA_HOME=/usr/local/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
"/etc/profile" 82L, 1949C written
[[email protected] ~]# source /etc/profile
测试java 是否成功
[[email protected] ~]# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
[[email protected] ~]# tar -zxvf apache-tomcat-8.0.15.tar.gz
安装tomcat
[[email protected] ~]# mkdir /usr/local/tomcat
[[email protected] ~]# mv apache-tomcat-8.0.15
apache-tomcat-8.0.15/ apache-tomcat-8.0.15.tar.gz
[[email protected] ~]# mv apache-tomcat-8.0.15/* /usr/local/tomcat/
设置tomcat 环境路径变量,catalina.sh 文件最后添加
[[email protected] ~]# vi /usr/local/tomcat/bin/catalina.sh
CATALINA_HOME=/usr/local/tomcat/
"/usr/local/tomcat/bin/catalina.sh" 581L, 21395C written
设置 脚本权限
[[email protected] ~]# chmod +x /usr/local/tomcat/bin/*.sh
[[email protected] ~]# /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/java/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
设置防火墙
[[email protected] ~]# iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
[[email protected] ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
[[email protected] ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
开启服务
[[email protected] ~]# ps -ef | grep java
root 2743 1 15 01:30 pts/1 00:00:11 /usr/local/java/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -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 2872 2636 1 01:31 pts/1 00:00:00 grep java
[[email protected] ~]# netstat -ano | grep 8080
tcp 0 0 :::8080 :::* LISTEN off (0.00/0/0)
tcp 0 0 ::ffff:192.168.98.194:8080 ::ffff:192.168.98.173:64260 TIME_WAIT timewait (54.27/0/0)
tcp 0 0 ::ffff:192.168.98.194:8080 ::ffff:192.168.98.173:64261 TIME_WAIT timewait (54.27/0/0)
[[email protected] ~]# /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/java/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[[email protected] ~]# /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/java/jre
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[[email protected] ~]#