安装jdk
cd /usr/local/src/ wget http://211.162.74.234:9011/download.oracle.com/c3pr90ntc0td/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz tar zxvf jdk-8u111-linux-x64.tar.gz mv jdk1.8.0_111 /usr/local/
配置
cat > /etc/profile.d/java.sh <<EOF AVA_HOME=/usr/local/jdk1.8.0_111 JAVA_BINE=/usr/local/jdk1.8.0_111/bin JRE_HOME=/usr/local/jdk1.8.0_111/jre PATH=$PATH:/usr/local/jdk1.8.0_111/bin:/usr/local/jdk1.8.0_111/jre/bin CLASSPATH=/usr/local/jdk1.8.0_111/jre/lib:/usr/local/jdk1.8.0_111/lib:/usr/local/jdk1.8.0_111/jre/lib/charsets.jar EOF
查看并卸载系统jdk
yum list|grep jdk yum remove java-1.6.0-openjdk.x86_64 java-1.7.0-openjdk.x86_64
使jdk配置生效并查看版本是否正确
. /etc/profile.d/java.sh java -version
下载安装tomcat
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.6/bin/apache-tomcat-8.5.6.tar.gz tar zxvf apache-tomcat-8.5.6.tar.gz mv apache-tomcat-8.5.6 /usr/local/tomcat cp -v /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat chmod 755 /etc/init.d/tomcat
修改tomcat配置
cat >> /etc/init.d/tomcat <<EOF # chkconfig: 2345 63 37 . /etc/init.d/functions JAVA_HOME=/usr/local/jdk1.8.0_111 CATALINA_HOME=/usr/local/tomcat EOF
添加服务开机自动启动
chkconfig --add tomcat
chkconfig tomcat on
启动&检查
/etc/init.d/tomcat start netstat -lnp curl -I localhost:8080