1、下載和解壓java
一、下載jdk和tomcatnode
wget http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.tar.gz
二、建立目錄/var/javalinux
三、解壓jdk和tomcat到/var/javaapache
tar -zxvf jdk-8u91-linux-x64.tar.gz -C /var/java/jdk1.8 tar -zxvf apache-tomcat-8.0.36.tar.gz -C /var/java/tomcat8
2、安裝JDKtomcat
一、查看當前系統是否存在jdkbash
rpm -qa|grep java
二、卸載當前jdkoracle
rpm -e --nodeps jdk
三、加入java的環境變量tcp
vi /etc/profile export JAVA_HOME=/opt/jdk1.8 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
四、使環境變量馬上生效code
source /etc/profile
五、查看java版本,確認是否安裝成功ip
java -version
3、安裝tomcat
一、啓動tomcat
cd /var/java/tomcat8/bin ./startup.sh
二、設置tomcat開機啓動
vi /etc/rc.local JAVA_HOME=/opt/jdk1.8 export JAVA_HOME /var/java/tomcat8/bin/startup.sh
三、開啓防火牆8080端口
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT