#centos安装jak和tomcat环境
[root@server1 tomcat]# ls
apache-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/profile
export JAVA_HOME=/usr/java/jdk1.8.0_40
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
[root@localhost tomcat]# source /etc/profile
[root@localhost tomcat]# java -version
java 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
<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
[root@server1 conf]# /usr/local/tomcat/bin/startup.sh 		
Using CATALINA_BASE:   /usr/local/tomcat/apache-tomcat-8.0.21
Using CATALINA_HOME:   /usr/local/tomcat/apache-tomcat-8.0.21
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-8.0.21/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_40
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-8.0.21/bin/tomc
at-juli.jarTomcat started.
[root@server1 tomcat]# netstat -tulnp | grep :80
tcp        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

CentOS 6.5安装Tomcat环境_tomcat

#tomcat启动脚本
[root@server1 tomcat]# vi /etc/init.d/tomcat
#!/bin/sh
#chkconfig: 2345 10 90
#description: Start and Stop the Tomcat

JAVA_HOME=/usr/java/jdk1.8.0_40
TOMCAT_HOME=/usr/local/tomcat

start_tomcat=$TOMCAT_HOME/bin/startup.sh
stop_tomcat=$TOMCAT_HOME/bin/shutdown.sh

start() {
    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}"
esac
exit 0
[root@server1 tomcat]# chmod a+x /etc/init.d/tomcat
[root@server1 tomcat]# /etc/init.d/tomcat restart