Tomcat

JDK:Java开发工具包
JRE: Java运行环境
SDK:辅助开发工具(短信商之列的)
J2EE:企业应用
J2SE:标准应用
J2ME:手机

中间件:tomcat resin jboss weblogic websphere
查看是否安装jdk
[root@minion ~]# rpm -qa|grep jdk
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
查找jdk安装路径,配置环境变量
[root@minion ~]# rpm -ql java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
/etc/.java
/etc/.java/.systemPrefs
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libsaproc.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libsctp.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libsplashscreen.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libunpack.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libverify.so
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64/jre/lib/amd64/libzip.so

设置环境变量
vim /etc/profile
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.45.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

让修改生效
[root@localhost java]# source /etc/profile

修改tomcat配置文件,然后把开发的代码放到/usr/local/tomcat/ROOT下
vim /etc/tomcat/server.xml

unpackWARs="true" autoDeploy="true">
mkdir /usr/local/tomcat/ROOT -p
vim index.jsp
Hello,tomcat home! The time is <%= new java.util.Date() %>

启动apache服务
service tomcat start

浏览器访问
http://192.168.56.21:8080/

++++++++++++++++++++++++++++++++++++++++++++
不用yum安装,可以源码安装
Tomcat/8.5.24

useradd -u 601 tomcat
passwd tomcat
密码也是tomcat

cd /usr/local/share
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz
tar -zxvf apache-tomcat-8.5.24.tar.gz

启动tomcat
/usr/local/share/apache-tomcat-8.5.24/bin/startup.sh

关闭tomcat
/usr/local/share/apache-tomcat-8.5.24/bin/shutdown.sh

查看启动日志
/usr/local/share/apache-tomcat-8.5.24/logs/catalina.out

访问tomcat
192.168.56.20:8080

修改配置文件位置
vim /usr/local/share/apache-tomcat-8.5.24/conf/server.xml

配置用户名和密码用于登录管理界面
vim /usr/local/share/apache-tomcat-8.5.24/conf/tomcat-users.xml


重启服务器,刷新访问的浏览器即可访问管理页面

优化
vim /usr/local/share/apache-tomcat-8.5.24/conf/server.xml
1、关闭8005端口
不然可以通过telnet 关闭tomcat
2、关闭8009端口不进行AJP调用(nginx一般用http,不用AJP)
3、更改webapp位置到tomcat以外的地方
4、tomcat用tomcat用户启动,不用root启动