Tomcat是一个web-server,类似nginx,apache的http
Nginx,http只能处理html等静态文件
网页分为静态和动态网页
Php承受并发能力1000,nginx承受能力10万
Nginx和http配合php就能够处理动态的网页(.php)
Tomcat也可以处理静态的html文件
Tomcat配合jdk就能够处理动态的网页.php结尾
Tomcat部署1.1.1安装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\nexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH\nexport CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile

source /etc/profile
安装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

Tomcat目录结构
.
├── bin #启动文件目录
├── conf #配置文件目录 server.xml(主配置文件)
├── lib #
├── LICENSE
├── logs #日志
├── NOTICE
├── RELEASE-NOTES
├── RUNNING.txt
├── temp #临时目录
├── webapps #站点存放目录
└── work#tomcat编译文件存放目录

利用浏览器访问:http://10.0.0.200:8080/

Tomcat日志
catalina.2018-03-01.log #catalina.2018-03-01.log 每天的日志文件切割
catalina.out #实时记录tomcat的运行信息,文件会越来越大,定时清空
#每个站点的访问日志
host-manager.2018-03-01.log
localhost.2018-03-01.log
localhost_access_log.2018-03-01.txt
manager.2018-03-01.log
1.[root@tomcat tomcat]# cd webapps/
2.[root@tomcat webapps]# ll
3.total 20
4.drwxr-xr-x 14 root root 4096 Oct 5 12:09 docs #→tomcat帮助文档
5.drwxr-xr-x 6 root root 4096 Oct 5 12:09 examples #→web应用实例
6.drwxr-xr-x 5 root root 4096 Oct 5 12:09 host-manager #→管理
7.drwxr-xr-x 5 root root 4096 Oct 5 12:09 manager #→管理
8.drwxr-xr-x 3 root root 4096 Oct 5 12:09 ROOT #→默认网站根目录

  1. #→启动程序/application/tomcat/bin/startup.sh
    2.#→关闭程序/application/tomcat/bin/shutdown.sh
    查看日志
    Tailf catalina.out
    Server startup in 11191 ms ##tomcat 已经启动完的标志
    1.2测试环境方法使用:把tomcat搭建好 然后把管理页面给开发
    Tomcat部署
    /application/tomcat/bin/shutdown.sh
    /application/tomcat/bin/startup.sh

1.3搭建jpress--java版本的wordpress
1.mysql安装:yum install mariadb-server
启动:systemctl start mariadb.service
2.mysq命令行操作:create database jpress DEFAULT CHARACTER SET utf8;
grant all on jpress.* to jpress@'localhost' identified by '123456';
2.部署站点代码
上传jpress-web-newest.war到/application/tomcat/webapps目录会自动解压
mv jpress-web-newest jpress
利用浏览器访问10.0.0.200/jpressTomcat部署Tomcat部署Tomcat部署4重启
/application/tomcat/bin/shutdown.sh
/application/tomcat/bin/startup.sh
5.后台登陆Tomcat部署vim /application/tomcat/conf/server.xml 语法:注释以<!--开头,以-->结尾

<Server port="8005" shutdown="SHUTDOWN">指定关闭tomcat的端口号及暗号

<Connector port="8080" protocol="HTTP/1.1" 指定监听tomcat的web站点监听端口
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />专门和apache通讯的端口

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

1.5

1.6自定义网站目录
默认:webapps下的ROOTTomcat部署1.将meminfo.jsp放在ROOT目录
sed -i.ori '125a <Context path="" docBase="/application/tomcat/webapps/memtest" debug="0" reloadable="false" crossContext="true"/>' /application/tomcat/conf/server.xml
重启: /application/tomcat/bin/shutdown.sh
/application/tomcat/bin/startup.sh
也可以不使用一下:
sed -i.ori2 '126a <Context path="43class" docBase="/application/tomcat/webapps/memtest" debug="0" reloadable="false" crossContext="true"/>' /application/tomcat/conf/server.xml
访问:http://10.0.0.200:8080/43class/meminfo.jsp
1.7Tomcat多实例
cd /server/tools/
tar xf apache-tomcat-8.0.27.tar.gz
cp -a apache-tomcat-8.0.27 tomcat_1
cp -a apache-tomcat-8.0.27 tomcat_2 多实例
sed -i 's#8005#8011#;s#8080#8081#' tomcat_1/conf/server.xml
sed -i 's#8005#8012#;s#8080#8082#' tomcat_2/conf/server.xml 配置过程
tar zcf tomcat_mtui.tar.gz ./tomcat_1/ tomcat_2/#将已经配置实例打包
mv tomcat_1/ tomcat_2/ /application/
/application/tomcat_1/bin/startup.sh
/application/tomcat_2/bin/startup.sh
netstat -lntup|grep javaTomcat部署1.8Tomcat反向代理
安装peplyum源yum -y install epel-release
安装nginx:yum -y install nginx
Vim /eyc/nginx/nginx.conf配置文件Tomcat部署Tomcat部署
利用浏览器访问10.0.0.200
1.9Tomcat远程监控Tomcat部署D:\监控tomcat\bin
双击Tomcat部署Tomcat部署Tomcat部署Tomcat部署Tomcat部署Tomcat部署Tomcat部署1.10Zabbix监控
安装zabbix-java-gateway

利用m01安装Tomcat部署rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm

yum -y install zabbix-java-qatewayTomcat部署
Tomcat部署1.12 浏览器输入:主机ip-配置-主机-创建主机
Tomcat部署Tomcat部署Tomcat部署1.13Tomcat优化
1.13.1安全优化
Telnet、nc管理端口保护(8005)

Ajp连接端口保护8009

禁用管理端

降权启动:降低权限启动tomcatTomcat部署Tomcat部署Tomcat部署Tomcat部署Tomcat部署1.13.2性能优化
vim /application/tomcat_1/bin/catalina.sh +97
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1024m -Xmx1024m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m -XX:MaxPermSize=512m"Tomcat部署