#centos安装jak和tomcat环境[root@server1 tomcat]# lsapache-tomcat-8.0.21.tar.gz  jdk-8u40-linux-x64.tar.gz[root@server1 tomcat]# mkdir /usr/java[root@server1 tomcat]# tar zxvf jdk-8u40-linux-x64.tar.gz -C /usr/java/[root@server1 tomcat]# vim /etc/profileexport JAVA_HOME=/usr/java/jdk1.8.0_40export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:$JAVA_HOME/bin[root@localhost tomcat]# source /etc/profile[root@localhost tomcat]# java -versionjava version "1.8.0_40"Java(TM) SE Runtime Environment (build 1.8.0_40-b26)Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)[root@server1 tomcat]# tar zxvf apache-tomcat-8.0.21.tar.gz[root@server1 tomcat]# mv apache-tomcat-8.0.21 /usr/local/tomcat[root@server1 tomcat]# vim /usr/local/tomcat/conf/server.xml
[root@server1 conf]# /usr/local/tomcat/bin/startup.sh  Using CATALINA_BASE:   /usr/local/tomcat/apache-tomcat-8.0.21Using CATALINA_HOME:   /usr/local/tomcat/apache-tomcat-8.0.21Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.0.21/tempUsing JRE_HOME:        /usr/java/jdk1.8.0_40Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-8.0.21/bin/tomcat-juli.jarTomcat started.[root@server1 tomcat]# netstat -tulnp | grep :80tcp        0      0 ::ffff:127.0.0.1:8005       :::*                        LISTEN      1497/java           tcp        0      0 :::8009                     :::*                        LISTEN      1497/java           tcp        0      0 :::80                       :::*                        LISTEN      1497/java#浏览器测试效果http://TomcatServerIP

#tomcat启动脚本[root@server1 tomcat]# vi /etc/init.d/tomcat#!/bin/sh#chkconfig: 2345 10 90#description: Start and Stop the TomcatJAVA_HOME=/usr/java/jdk1.8.0_40TOMCAT_HOME=/usr/local/tomcatstart_tomcat=$TOMCAT_HOME/bin/startup.shstop_tomcat=$TOMCAT_HOME/bin/shutdown.shstart() {    echo -n "Starting tomcat: "    ${start_tomcat}    echo "tomcat start ok"}stop() {    echo -n "Shutdown tomcat"    ${stop_tomcat}    echo "tomcat stop ok"}case "$1" in    start)        start        ;;    stop)        stop        ;;    restart)        stop        sleep 10        start        ;;    *)        echo "Usage: $0 {start|stop|restart}"esacexit 0[root@server1 tomcat]# chmod a+x /etc/init.d/tomcat[root@server1 tomcat]# /etc/init.d/tomcat restart