1. Tomcat简介
Tomcat是一个web服务器
web服务器:httpd,nginx
web 处理静态文件:html css、js、jpg,png Tomcat 处理 html文件 php软件解析php文件 jdk处理jsp文件 tomcat+JDK
JDK java开发者工具包
java 写一次,处处使用
jdk java虚拟机
跨平台
2. tomcat软件版本选择
生产环境版本和开发协商
tomcat和jdk版本要并行 tomcat8 -- jdk 8
3. 安装JDK(以后所有涉及到java应用都需要安装)
tar xf jdk-8u60-linux-x64.tar.gz -C /application/ ln -s /application/jdk1.8.0_60 /application/jdk sed -i.ori '$a export JAVA_HOME=/application/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile source /etc/profile
java -version
4. 安装tomcat
tar xf apache-tomcat-8.0.27.tar.gz -C /application/ ln -s /application/apache-tomcat-8.0.27 /application/tomcat echo 'export TOMCAT_HOME=/application/tomcat'>>/etc/profile source /etc/profile chown -R root.root /application/jdk/ /application/tomcat/
/application/tomcat/bin/version.sh
5. tomcat的目录结构
[root@web03 tools]# cd /application/tomcat/ [root@web03 tomcat]# tree -L 1 . ├── bin startup.sh shutdown.sh catalina.sh(核心) ├── conf server.xml(主配置文件) tomcat-users.xml ├── lib ├── LICENSE ├── logs 日志目录 catalina.out tomcat实时日志 ├── NOTICE ├── RELEASE-NOTES ├── RUNNING.txt ├── temp ├── webapps 站点目录 └── work
7 directories, 4 files
6. 启动关闭tomcat
/application/tomcat/bin/startup.sh /application/tomcat/bin/shutdown.sh
netstat -tunlp|grep java
http://10.0.0.17:8080/
7. tomcat 管理功能
[root@web03 webapps]# tail -4 /application/tomcat/conf/tomcat-users.xml <role rolename="manager-gui"/> <role rolename="admin-gui"/> <user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/> </tomcat-users>
/application/tomcat/bin/shutdown.sh /application/tomcat/bin/startup.sh
8.Tomcat主配置文件
vim /application/tomcat/conf/server.xml
<Server port="8005" shutdown="SHUTDOWN">
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<!--<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />-->
9. 自定义url规则(nginx location)
cp /application/tomcat/conf/server.xml{,.ori}
vim /application/tomcat/conf/server.xml +125 # nginx server root html; <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="/application/tomcat/webapps/memtest" debug="0" reloadable="false" crossContext="true"/> <Context path="/40team" docBase="/application/tomcat/webapps/memtest" debug="0" reloadable="false" crossContext="true"/>
============= nginx location root html location / location /oldboy/ { root /data/oldboy/ } ======
/application/tomcat/bin/shutdown.sh /application/tomcat/bin/startup.sh
10. 搭建Jpress
类似wordpess博客站点
环境:Linux Tomcat JDK MySQL(Mariadb)
yum -y install mariadb-server systemctl start mariadb.service
mysql create database jpress DEFAULT CHARACTER SET utf8; grant all on jpress.* to jpress@'localhost' identified by '123456';
今日总结: 1. tomcat jdk安装 2. tomcat使用,配置文件,日志,站点目录,启动文件 3. java程序jpress
课后作业: 1. 搭建conflunce和jira https://www.ilanni.com/?p=11989 https://www.ilanni.com/?p=12119
下周一: tomcat 多实例 tomcat 集群 tomcat 监控(zabbix) tomcat 优化
周二,周三 LVS
周四 周五 下下周一 git