2 、安装 JDK 1、命令集 2、测试jdk是否安装成功 3、安装Tomcat 4、检查tomcat是否安装成功 3、Tomcat 的管理 4、检查tomcat是否启动正常 5、Tomcat 日志说明 上线的代码有两种方式: 1、直接部署 web 站点 站点部署 2、自定义默认网站目录 方法二 修改配置文件后,要重启服务 7、Tomcat 多实例配置 多实例(多进程):同一个程序启动多次,分为两种情况: 第一种:一台机器跑多个站点; 第二种:一个机器跑一个站点多个实例,配合负载均衡 1、复制程序文件 2、修改端口,以启动多实例。多实例之间端口不能一致 3、将配置好的tomcat程序打包,以备之后使用 4、启动tomcat多实例 5、检查端口是否启动 6、将每个实例的网页进行区分 7、在浏览器访问,进行测试
安装 Tomcat & JDK
1、系统环境说明[root@test.com ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) [root@test.com ~]# uname -a Linux test.com 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux [root@test.com ~]# getenforce Disabled [root@test.com ~]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)
[root@test.com ~]# tar xf jdk-8u201-linux-x64.tar.gz -C /usr/local/ [root@test.com ~]# cd /usr/local/ [root@test.com local]# ln -s jdk1.8.0_201/ java # 设置环境变量 [root@test.com ~]# vim /etc/profile export JAVA_HOME=/usr/local/java export JRE_HOME=/usr/local/java/jre export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH [root@test.com ~]# source /etc/profile
[root@test.com ~]# java -version java version "jdk1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
[root@test.com ~]# tar xf apache-tomcat-8.0.27.tar.gz -C /usr/local/ [root@test.com ~]# cd /usr/local/ [root@test.com ~]# ln -s /usr/laocal/apache-tomcat-8.0.27 /usr/local/tomcat # 设置环境变量 [root@test.com ~]# vim /etc/profile export JAVA_HOME=/usr/local/java export TOMCAT_HOME=/usr/local/tomcat export JRE_HOME=/usr/local/java/jre export PATH=$TOMCAT_HOME/bin:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH # 注意授权,统一权限 [root@test.com ~]# chown -R root.root /usr/local/jdk/ /usr/local/tomcat/
[root@test.com ~]# /usr/local/tomcat/bin/version.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/local/jdk Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Server version: Apache Tomcat/8.0.27 Server built: Sep 28 2015 08:17:25 UTC Server number: 8.0.27.0 OS Name: Linux OS Version: 3.10.0-693.el7.x86_64 Architecture: amd64 JVM Version: 1.8.0_60-b27 JVM Vendor: Oracle Corporation
# 启动程序/usr/local/tomcat/bin/startup.sh # 关闭程序/usr/local/tomcat/bin/shutdown.sh
[root@test.com ~]# netstat -lntup |grep java tcp6 0 0 :::8080 :::* LISTEN 30560/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 30560/java tcp6 0 0 :::8009 :::* LISTEN 30560/java
[root@test.com ~]# tailf /usr/local/tomcat/logs/catalina.out 24-Nov-2017 15:09:51.654 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"] 24-Nov-2017 15:09:51.665 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"] 24-Nov-2017 15:09:51.670 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 60037 ms
6、WEB站点部署
[root@test.com webapps]# pwd /usr/local/tomcat/webapps [root@test.com webapps]# [root@test.com webapps]# cat /usr/local/tomcat/webapps/memtest/meminfo.jsp <% Runtime rtm = Runtime.getRuntime(); long mm = rtm.maxMemory()/1024/1024; long tm = rtm.totalMemory()/1024/1024; long fm = rtm.freeMemory()/1024/1024; out.println("JVM memory detail info :<br>"); out.println("Max memory:"+mm+"MB"+"<br>"); out.println("Total memory:"+tm+"MB"+"<br>"); out.println("Free memory:"+fm+"MB"+"<br>"); out.println("Available memory can be used is :"+(mm+fm-tm)+"MB"+"<br>"); %>
[root@test.com webapps]# ls docs examples host-manager logs manager memtest memtest.war ROOT
方法一
[root@test.com ~]# vim /usr/local/tomcat/conf/server.xml +125 …… #添加上这两行 <Context path="" docBase="/usr/local/tomcat/webapps/memtest" debug="0" reloadable="false" crossContext="true"/> <Context path="/40team" docBase="/usr/local/tomcat/webapps/memtest" debug="0" reloadable="false" crossContext="true"/> ……
[root@test.com ~]# /usr/local/tomcat/bin/shutdown.sh [root@test.com ~]# /usr/local/tomcat/bin/startup.sh
多虚拟主机:nginx 多个Server标签(域名,ip,端口) 进程数量固定 master+worker[root@test.com ~]# cd /usr/local/tools/ [root@test.com ~]# tar xf apache-tomcat-8.0.27.tar.gz [root@test.com ~]# cp -a apache-tomcat-8.0.27 tomcat8_1 [root@test.com ~]# cp -a apache-tomcat-8.0.27 tomcat8_2
[root@test.com ~]# sed -i 's#8005#8011#;s#8080#8081#' tomcat8_1/conf/server.xml [root@test.com ~]# sed -i 's#8005#8012#;s#8080#8082#' tomcat8_2/conf/server.xml [root@test.com application]# diff tomcat8_1/conf/server.xml tomcat8_2/conf/server.xml 22c22 < <Server port="8011" shutdown="SHUTDOWN"> --- > <Server port="8012" shutdown="SHUTDOWN"> 67c67 < Define a non-SSL/TLS HTTP/1.1 Connector on port 8081 --- > Define a non-SSL/TLS HTTP/1.1 Connector on port 8082 69c69 < <Connector port="8081" protocol="HTTP/1.1" --- > <Connector port="8082" protocol="HTTP/1.1" 75c75 < port="8081" protocol="HTTP/1.1" --- > port="8082" protocol="HTTP/1.1"
[root@test.com ~]# tar zcf muti_tomcat8.tar.gz ./tomcat8_1 ./tomcat8_2
[root@test.com ~]# /usr/local/tomcat8_1/bin/startup.sh [root@test.com ~]# /usr/local/tomcat8_2/bin/startup.sh
[root@test.com tomcat8_1]# netstat -lntup |grep java tcp6 0 0 127.0.0.1:8011 :::* LISTEN 31906/java tcp6 0 0 127.0.0.1:8012 :::* LISTEN 31932/java tcp6 0 0 :::8080 :::* LISTEN 31812/java tcp6 0 0 :::8081 :::* LISTEN 31906/java tcp6 0 0 :::8082 :::* LISTEN 31932/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 31812/java tcp6 0 0 :::8009 :::* LISTEN 31812/java
[root@test.com ~]# echo 8081 >>/usr/local/tomcat8_1/webapps/ROOT/index.jsp [root@test.com ~]# echo 8082 >>/usr/local/tomcat8_2/webapps/ROOT/index.jsp
使用curl 命令进行测试,awk 进行关键字提取[root@test.com ~]# curl -s 10.0.0.5|awk 'END{print}' 8082 [root@test.com ~]# curl -s 10.0.0.5|awk 'END{print}' 8081
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算