标签:tomcat java
Tomcat是由Apache软件基金会下属的Jakarta项目开发的一个Servlet容器,按照Sun Microsystems提供的技术规范, 实现了对Servlet和JavaServer Page(JSP)的支持。由于Tomcat本身也内含了一个HTTP服务器,它也可以被视作一个单独的Web服务器。 一、基础环境 1、版本 cat /etc/debian_version 7.8 2、内核 uname -r 3.2.0-4-amd64 3、安装包 1)jdk-8u51-linux-x64.tar.gz 2)apache-tomcat-8.0.23.tar.gz 4、ip(eth0) 10.1.10.117 5、java官网 http://www.oracle.com/technetwork/java/javase/downloads/index.html 6、tomcat官网 http://tomcat.apache.org/ 二、安装java环境 1、下载 wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz" 2、创建目录 mkdir -p /opt/java 3、解压 tar zxvf jdk-8u51-linux-x64.tar.gz -C /opt/java/ 4、配置java的环境变量 cat /etc/profile export JAVA_HOME=/opt/java/jdk1.8.0_51 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 5、生效 source /etc/profile 6、查看 echo $JAVA_HOME /opt/java/jdk1.8.0_51 echo $PATH /opt/java/jdk1.8.0_51/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin echo $CLASSPATH /opt/java/jdk1.8.0_51/lib/dt.jar:/opt/java/jdk1.8.0_51/lib/tools.jar 7、查看java版本 1)java -version java version "1.8.0_51" Java(TM) SE Runtime Environment (build 1.8.0_51-b16) Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode) 2)相关目录说明 bin 用以启动、关闭Tomcat或者其它功能的脚本(.bat文件和.sh文件) conf 用以配置Tomcat的XML及DTD文件 logs Catalina和其它Web应用程序的日志文件 temp 临时文件 webapps Web应用程序根目录 work 用以产生有JSP编译出的Servlet的.java和.class文件 8、使用jps命令查看相关java信息 1)jps -mlv 11885 sun.tools.jps.Jps -mlv -Denv.class.path=.:/opt/java/jdk1.8.0_51/lib/dt.jar:/opt/java/jdk1.8.0_51/lib/tools.jar -Dapplication.home=/opt/java/jdk1.8.0_51 -Xms8m 20参数说明 -m Displays the arguments passed to the main method.The output may be null for embedded JVMs(输出main method的参数) -l Displays the full package name for the application s main class or the full path name to the application s JAR file(输出完全的包名,应用主类名,jar的完全路径名) -v Displays the arguments passed to the JVM(输出jvm参数) 三、安装tomcat 1、下载 axel -n 10 http://mirrors.ustc.edu.cn/apache/tomcat/tomcat-8/v8.0.23/bin/apache-tomcat-8.0.23.tar.gz 2、创建目录 mkdir /opt/tomcat -p 3、解压 tar zxvf apache-tomcat-8.0.23.tar.gz -C /opt/tomcat 4、制作启动脚本 cp /opt/tomcat/apache-tomcat-8.0.23/bin/catalina.sh /etc/init.d/tomcat 5、配置tomcat环境变量 cat /etc/profile export TOMCAT_HOME=/opt/tomcat/apache-tomcat-8.0.23 export CATALINA_HOME=$TOMCAT_HOME export CATALINA_BASE=$TOMCAT_HOME export CATALINA_TMPDIR=$TOMCAT_HOME/temp 6、启动tomcat服务 /etc/init.d/tomcat start Using CATALINA_BASE: /opt/tomcat/apache-tomcat-8.0.23 Using CATALINA_HOME: /opt/tomcat/apache-tomcat-8.0.23 Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-8.0.23/temp Using JRE_HOME: /opt/java/jdk1.8.0_51 Using CLASSPATH: /opt/tomcat/apache-tomcat-8.0.23/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.0.23/bin/tomcat-juli.jar Tomcat started. 7、查看进程 ps -ef|grep java root 12697 1 10 14:26 pts/0 00:00:03 /opt/java/jdk1.8.0_51/bin/java -Djava.util.logging.config.file=/opt/tomcat/apache-tomcat-8.0.23/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat/apache-tomcat-8.0.23/endorsed -classpath /opt/tomcat/apache-tomcat-8.0.23/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-8.0.23/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat/apache-tomcat-8.0.23 -Dcatalina.home=/opt/tomcat/apache-tomcat-8.0.23 -Djava.io.tmpdir=/opt/tomcat/apache-tomcat-8.0.23/temp org.apache.catalina.startup.Bootstrap start 8、查看端口 netstat -tupnl|grep java tcp6 0 0 :::8009 :::* LISTEN 12848/java tcp6 0 0 :::8080 :::* LISTEN 12848/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 12848/java 9、使用jps命令查看相关java信息 jps -mlv 13093 sun.tools.jps.Jps -mlv -Denv.class.path=/opt/java/jdk1.8.0_51/lib/dt.jar:/opt/java/jdk1.8.0_51/lib/tools.jar -Dapplication.home=/opt/java/jdk1.8.0_51 -Xms8m 13071 org.apache.catalina.startup.Bootstrap start -Djava.util.logging.config.file=/opt/tomcat/apache-tomcat-8.0.23/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/tomcat/apache-tomcat-8.0.23/endorsed -Dcatalina.base=/opt/tomcat/apache-tomcat-8.0.23 -Dcatalina.home=/opt/tomcat/apache-tomcat-8.0.23 -Djava.io.tmpdir=/opt/tomcat/apache-tomcat-8.0.23/temp 10、相关日志 ll /opt/tomcat/apache-tomcat-8.0.23/logs -rw-r--r-- 1 root root 27851 Jul 15 16:26 catalina.2015-07-15.log -rw-r--r-- 1 root root 27851 Jul 15 16:26 catalina.out -rw-r--r-- 1 root root 0 Jul 15 13:49 host-manager.2015-07-15.log -rw-r--r-- 1 root root 1948 Jul 15 16:26 localhost.2015-07-15.log -rw-r--r-- 1 root root 1439 Jul 15 16:37 localhost_access_log.2015-07-15.txt -rw-r--r-- 1 root root 0 Jul 15 13:49 manager.2015-07-15.log 11、查看效果
四、参考文章 https://ivan-site.com/2012/05/download-oracle-java-jre-jdk-using-a-script/
本文出自 “7928217” 博客,请务必保留此出处http://7938217.blog.51cto.com/7928217/1677272
标签:tomcat java
原文地址:http://7938217.blog.51cto.com/7928217/1677272