1。安裝JDKjava
官網下載,或者用winscp工具下載後解壓linux
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-i586.tar.gzapache
tar zxvf jdk-8u65-linux-x64.tar.gzvim
mv jdk1.8.0_73 /usr/local/jdk1.8.0_73tomcat
vi /etc/profile.d/java.sh //加入以下配置cookie
JAVA_HOME=/usr/local/jdk1.8.0_73oracle
JAVA_BIN=/usr/local/jdk1.8.0_73/binide
JRE_HOME=/usr/local/jdk1.8.0_73/jre工具
PATH=$PATH:/usr/local/jdk1.8.0_73/bin:/usr/local/jdk1.8.0_73/jre/binspa
CLASSPATH=/usr/local/jdk1.8.0_73/jre/lib:/usr/local/jdk1.8.0_73/lib:/usr/local/jdk1.8.0_73/jre/lib/charsets.jar
source /etc/profile.d/java.sh
若是以上配置成功,則下面的命令能夠看到java的版本:
java -version
2。安裝tomcat
cd /usr/local/src/;
wget http://www.lishiming.net/data/p_w_upload/forum/apache-tomcat-7.0.14.tar.gz
tar zxvf apache-tomcat-7.0.14.tar.gz
mv apache-tomcat-7.0.14 /usr/local/tomcat (tomcat目錄不用建立)
cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
vim /etc/init.d/tomcat //從第二行加入
# chkconfig: 2345 63 37
# description: tomcat server init script
# Source Function Library
. /etc/init.d/functions
JAVA_HOME=/usr/local/jdk1.8.0_73
CATALINA_HOME=/usr/local/tomcat
chmod 755 /etc/init.d/tomcat
service tomcat start(systemctl start tomcat)
ps aux |grep tomcat
netstat -lnp |grep 8080
關閉防火牆:
iptables -F
setenforce 0
systemctl disable firewalld.service #禁止firewall開機啓動
systemctl stop firewalld
經過如下地址查看tomcat是否運行正常:
http://192.168.15.231:8080/
看到tomcat系統界面,說明安裝成功!